Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Lost link between GridView and DetailsView

Reply
Thread Tools

Lost link between GridView and DetailsView

 
 
VB Programmer
Guest
Posts: n/a
 
      10-08-2007
For some reason, when I select the record in my GridView the DetailsView
doesn't show up anymore. What "links" the 2?

The DetailsView is based on an SQLDataSource with a WHERE clause using the
value from the GridView.

Any ideas?

Here's the definitions...

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4"
DataSourceID="SqlDataSource1" ForeColor="#333333"
GridLines="None" DataKeyNames="ProgramId">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
/>
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="ProgramName" HeaderText="Program"
SortExpression="ProgramName">
<ItemStyle Width="200px" />
</asp:BoundField>
<asp:BoundField DataField="ProgramId" HeaderText="ProgramId"
InsertVisible="False"
ReadOnly="True" SortExpression="ProgramId" Visible="False"
/>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton runat="server" ID="btnDelete"
CommandName="Delete" OnClientClick="return confirm('Are you sure you want to
PERMANENTLY DELETE this record and ALL associated records?');"
Text="Delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
/>
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>

<aspetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
CellPadding="4"
DataKeyNames="ProgramId" DataSourceID="sdsProgramDetails"
ForeColor="#333333" GridLines="None"
Height="50px" Width="465px">
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
/>
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<EditRowStyle BackColor="#999999" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<Fields>
<asp:BoundField DataField="ProgramName" HeaderText="Program
Name" SortExpression="ProgramName" />
<asp:CheckBoxField DataField="ActiveProgram" HeaderText="Active"
SortExpression="ActiveProgram" />
<asp:BoundField DataField="ProgramId" HeaderText="ProgramId"
InsertVisible="False"
ReadOnly="True" SortExpression="ProgramId" Visible="False"
/>
<asp:TemplateField HeaderText="Program Type"
SortExpression="ProgramTypeId">
<EditItemTemplate>
<aspropDownList ID="DropDownList1" runat="server"
DataSourceID="sdsProgTypes" DataTextField="ProgramType"
DataValueField="ProgramTypeId" SelectedValue='<%#
Bind("ProgramTypeId") %>' Width="269px">
</aspropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<aspropDownList ID="DropDownList1" runat="server"
DataSourceID="sdsProgTypes" DataTextField="ProgramType"
DataValueField="ProgramTypeId" SelectedValue='<%#
Bind("ProgramTypeId") %>' Width="269px">
</aspropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("ProgramType") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="MaxClients" HeaderText="Max Clients"
SortExpression="MaxClients" />
<asp:TemplateField HeaderText="Start Date"
SortExpression="StartDate">
<EditItemTemplate>
<asp:Calendar ID="Calendar1" runat="server"
BackColor="White" BorderColor="White"
BorderWidth="1px" Font-Names="Verdana"
Font-Size="9pt" ForeColor="Black" Height="170px"
NextPrevFormat="FullMonth" SelectedDate='<%#
Bind("StartDate") %>' Width="274px">
<SelectedDayStyle BackColor="#333399"
ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt"
ForeColor="#333333" VerticalAlign="Bottom" />
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<TitleStyle BackColor="White" BorderColor="Black"
BorderWidth="4px" Font-Bold="True"
Font-Size="12pt" ForeColor="#333399" />
</asp:Calendar>
</EditItemTemplate>
<InsertItemTemplate>
<asp:Calendar ID="Calendar1" runat="server"
BackColor="White" BorderColor="White"
BorderWidth="1px" Font-Names="Verdana"
Font-Size="9pt" ForeColor="Black" Height="170px"
NextPrevFormat="FullMonth" SelectedDate='<%#
Bind("StartDate") %>' Width="274px">
<SelectedDayStyle BackColor="#333399"
ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt"
ForeColor="#333333" VerticalAlign="Bottom" />
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<TitleStyle BackColor="White" BorderColor="Black"
BorderWidth="4px" Font-Bold="True"
Font-Size="12pt" ForeColor="#333399" />
</asp:Calendar>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%#
Bind("StartDate", "{0:d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="DefaultMgmtFee" HeaderText="Default
Mgmt Fee" SortExpression="DefaultMgmtFee" />
<asp:TemplateField HeaderText="Fee Type"
SortExpression="MgmtFeeType">
<EditItemTemplate>
<aspropDownList ID="DropDownList2" runat="server"
SelectedValue='<%# Bind("MgmtFeeType") %>'>
<asp:ListItem>%</asp:ListItem>
<asp:ListItem>$</asp:ListItem>
</aspropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<aspropDownList ID="DropDownList2" runat="server"
SelectedValue='<%# Bind("MgmtFeeType") %>'>
<asp:ListItem>%</asp:ListItem>
<asp:ListItem>$</asp:ListItem>
</aspropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("MgmtFeeType") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ReoccuranceNumber"
HeaderText="Reoccur #" SortExpression="ReoccuranceNumber" />
<asp:TemplateField HeaderText="Reoccur Interval"
SortExpression="Reoccurance">
<EditItemTemplate>
<aspropDownList ID="DropDownList3" runat="server"
DataSourceID="sdsReoccur" DataTextField="Reoccurance"
DataValueField="ReoccuranceId" SelectedValue='<%#
Bind("ReoccuranceId") %>'>
</aspropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<aspropDownList ID="DropDownList3" runat="server"
DataSourceID="sdsReoccur" DataTextField="Reoccurance"
DataValueField="ReoccuranceId" SelectedValue='<%#
Bind("ReoccuranceId") %>'>
</aspropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%#
Bind("Reoccurance") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Comments" HeaderText="Comments"
SortExpression="Comments" >
<ItemStyle Width="300px" />
</asp:BoundField>
<asp:CommandField ShowEditButton="True" ShowInsertButton="True"
/>
</Fields>
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
/>
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</aspetailsView>


<asp:SqlDataSource ID="sdsProgramDetails" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
DeleteCommand="DELETE FROM [Programs] WHERE
[ProgramId] = @ProgramId" InsertCommand="INSERT INTO [Programs]
([ProgramTypeId], [ProgramName], [ActiveProgram], [MaxClients], [StartDate],
[DefaultMgmtFee], [MgmtFeeType], [Comments]) VALUES (@ProgramTypeId,
@ProgramName, @ActiveProgram, @MaxClients, @StartDate, @DefaultMgmtFee,
@MgmtFeeType, @Comments)"
SelectCommand="SELECT Programs.ProgramId,
Programs.ProgramTypeId, Programs.ProgramName, Programs.ActiveProgram,
Programs.MaxClients, Programs.StartDate, Programs.DefaultMgmtFee,
Programs.MgmtFeeType, Programs.Comments, ProgramTypes.ProgramType,
Programs.ReoccuranceNumber, Programs.ReoccuranceId, Reoccurance.Reoccurance
FROM Programs INNER JOIN ProgramTypes ON Programs.ProgramTypeId =
ProgramTypes.ProgramTypeId INNER JOIN Reoccurance ON Programs.ReoccuranceId
= Reoccurance.ReoccuranceId WHERE (Programs.ProgramId = @ProgramId)"
UpdateCommand="UPDATE [Programs] SET [ProgramTypeId] = @ProgramTypeId,
[ProgramName] = @ProgramName, [ActiveProgram] = @ActiveProgram, [MaxClients]
= @MaxClients, [StartDate] = @StartDate, [DefaultMgmtFee] = @DefaultMgmtFee,
[MgmtFeeType] = @MgmtFeeType, [Comments] = @Comments WHERE [ProgramId] =
@ProgramId">
<DeleteParameters>
<asparameter Name="ProgramId" Type="Int32"
/>
</DeleteParameters>
<UpdateParameters>
<asparameter Name="ProgramTypeId"
Type="Int32" />
<asparameter Name="ProgramName"
Type="String" />
<asparameter Name="ActiveProgram"
Type="Boolean" />
<asparameter Name="MaxClients"
Type="Int32" />
<asparameter Name="StartDate"
Type="DateTime" />
<asparameter Name="DefaultMgmtFee"
Type="Decimal" />
<asparameter Name="MgmtFeeType"
Type="String" />
<asparameter Name="Comments" Type="String"
/>
<asparameter Name="ProgramId" Type="Int32"
/>
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="GridView1"
Name="ProgramId" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<InsertParameters>
<asparameter Name="ProgramTypeId"
Type="Int32" />
<asparameter Name="ProgramName"
Type="String" />
<asparameter Name="ActiveProgram"
Type="Boolean" />
<asparameter Name="MaxClients"
Type="Int32" />
<asparameter Name="StartDate"
Type="DateTime" />
<asparameter Name="DefaultMgmtFee"
Type="Decimal" />
<asparameter Name="MgmtFeeType"
Type="String" />
<asparameter Name="Comments" Type="String"
/>
</InsertParameters>
</asp:SqlDataSource>


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      10-09-2007
Your datasources are linked correctly. You need to handle the gridview's
SelectedIndexChanged event like this:

protected void GridView1_OnSelectedIndexChanged(Object sender, EventArgs e)

{

this.sdsProgramDetails.Select(System.Web.UI.DataSo urceSelectArguments.Empty);

this.DetailsView1.DataBind();

}


--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"VB Programmer" <> wrote in message
news:%...
> For some reason, when I select the record in my GridView the DetailsView
> doesn't show up anymore. What "links" the 2?
>
> The DetailsView is based on an SQLDataSource with a WHERE clause using the
> value from the GridView.
>
> Any ideas?
>
> Here's the definitions...
>
> <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
> AllowSorting="True"
> AutoGenerateColumns="False" CellPadding="4"
> DataSourceID="SqlDataSource1" ForeColor="#333333"
> GridLines="None" DataKeyNames="ProgramId">
> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
> />
> <Columns>
> <asp:CommandField ShowSelectButton="True" />
> <asp:BoundField DataField="ProgramName" HeaderText="Program"
> SortExpression="ProgramName">
> <ItemStyle Width="200px" />
> </asp:BoundField>
> <asp:BoundField DataField="ProgramId" HeaderText="ProgramId"
> InsertVisible="False"
> ReadOnly="True" SortExpression="ProgramId" Visible="False"
> />
> <asp:TemplateField>
> <ItemTemplate>
> <asp:LinkButton runat="server" ID="btnDelete"
> CommandName="Delete" OnClientClick="return confirm('Are you sure you want
> to PERMANENTLY DELETE this record and ALL associated records?');"
> Text="Delete"></asp:LinkButton>
> </ItemTemplate>
> </asp:TemplateField>
> </Columns>
> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
> <EditRowStyle BackColor="#999999" />
> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
> ForeColor="#333333" />
> <PagerStyle BackColor="#284775" ForeColor="White"
> HorizontalAlign="Center" />
> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
> />
> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
> </asp:GridView>
>
> <aspetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
> CellPadding="4"
> DataKeyNames="ProgramId" DataSourceID="sdsProgramDetails"
> ForeColor="#333333" GridLines="None"
> Height="50px" Width="465px">
> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
> />
> <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
> <EditRowStyle BackColor="#999999" />
> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
> <PagerStyle BackColor="#284775" ForeColor="White"
> HorizontalAlign="Center" />
> <Fields>
> <asp:BoundField DataField="ProgramName" HeaderText="Program
> Name" SortExpression="ProgramName" />
> <asp:CheckBoxField DataField="ActiveProgram"
> HeaderText="Active" SortExpression="ActiveProgram" />
> <asp:BoundField DataField="ProgramId" HeaderText="ProgramId"
> InsertVisible="False"
> ReadOnly="True" SortExpression="ProgramId" Visible="False"
> />
> <asp:TemplateField HeaderText="Program Type"
> SortExpression="ProgramTypeId">
> <EditItemTemplate>
> <aspropDownList ID="DropDownList1" runat="server"
> DataSourceID="sdsProgTypes" DataTextField="ProgramType"
> DataValueField="ProgramTypeId" SelectedValue='<%#
> Bind("ProgramTypeId") %>' Width="269px">
> </aspropDownList>
> </EditItemTemplate>
> <InsertItemTemplate>
> <aspropDownList ID="DropDownList1" runat="server"
> DataSourceID="sdsProgTypes" DataTextField="ProgramType"
> DataValueField="ProgramTypeId" SelectedValue='<%#
> Bind("ProgramTypeId") %>' Width="269px">
> </aspropDownList>
> </InsertItemTemplate>
> <ItemTemplate>
> <asp:Label ID="Label2" runat="server" Text='<%#
> Bind("ProgramType") %>'></asp:Label>
> </ItemTemplate>
> </asp:TemplateField>
> <asp:BoundField DataField="MaxClients" HeaderText="Max Clients"
> SortExpression="MaxClients" />
> <asp:TemplateField HeaderText="Start Date"
> SortExpression="StartDate">
> <EditItemTemplate>
> <asp:Calendar ID="Calendar1" runat="server"
> BackColor="White" BorderColor="White"
> BorderWidth="1px" Font-Names="Verdana"
> Font-Size="9pt" ForeColor="Black" Height="170px"
> NextPrevFormat="FullMonth" SelectedDate='<%#
> Bind("StartDate") %>' Width="274px">
> <SelectedDayStyle BackColor="#333399"
> ForeColor="White" />
> <TodayDayStyle BackColor="#CCCCCC" />
> <OtherMonthDayStyle ForeColor="#999999" />
> <NextPrevStyle Font-Bold="True" Font-Size="8pt"
> ForeColor="#333333" VerticalAlign="Bottom" />
> <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
> <TitleStyle BackColor="White" BorderColor="Black"
> BorderWidth="4px" Font-Bold="True"
> Font-Size="12pt" ForeColor="#333399" />
> </asp:Calendar>
> </EditItemTemplate>
> <InsertItemTemplate>
> <asp:Calendar ID="Calendar1" runat="server"
> BackColor="White" BorderColor="White"
> BorderWidth="1px" Font-Names="Verdana"
> Font-Size="9pt" ForeColor="Black" Height="170px"
> NextPrevFormat="FullMonth" SelectedDate='<%#
> Bind("StartDate") %>' Width="274px">
> <SelectedDayStyle BackColor="#333399"
> ForeColor="White" />
> <TodayDayStyle BackColor="#CCCCCC" />
> <OtherMonthDayStyle ForeColor="#999999" />
> <NextPrevStyle Font-Bold="True" Font-Size="8pt"
> ForeColor="#333333" VerticalAlign="Bottom" />
> <DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
> <TitleStyle BackColor="White" BorderColor="Black"
> BorderWidth="4px" Font-Bold="True"
> Font-Size="12pt" ForeColor="#333399" />
> </asp:Calendar>
> </InsertItemTemplate>
> <ItemTemplate>
> <asp:Label ID="Label3" runat="server" Text='<%#
> Bind("StartDate", "{0:d}") %>'></asp:Label>
> </ItemTemplate>
> </asp:TemplateField>
> <asp:BoundField DataField="DefaultMgmtFee" HeaderText="Default
> Mgmt Fee" SortExpression="DefaultMgmtFee" />
> <asp:TemplateField HeaderText="Fee Type"
> SortExpression="MgmtFeeType">
> <EditItemTemplate>
> <aspropDownList ID="DropDownList2" runat="server"
> SelectedValue='<%# Bind("MgmtFeeType") %>'>
> <asp:ListItem>%</asp:ListItem>
> <asp:ListItem>$</asp:ListItem>
> </aspropDownList>
> </EditItemTemplate>
> <InsertItemTemplate>
> <aspropDownList ID="DropDownList2" runat="server"
> SelectedValue='<%# Bind("MgmtFeeType") %>'>
> <asp:ListItem>%</asp:ListItem>
> <asp:ListItem>$</asp:ListItem>
> </aspropDownList>
> </InsertItemTemplate>
> <ItemTemplate>
> <asp:Label ID="Label1" runat="server" Text='<%#
> Bind("MgmtFeeType") %>'></asp:Label>
> </ItemTemplate>
> </asp:TemplateField>
> <asp:BoundField DataField="ReoccuranceNumber"
> HeaderText="Reoccur #" SortExpression="ReoccuranceNumber" />
> <asp:TemplateField HeaderText="Reoccur Interval"
> SortExpression="Reoccurance">
> <EditItemTemplate>
> <aspropDownList ID="DropDownList3" runat="server"
> DataSourceID="sdsReoccur" DataTextField="Reoccurance"
> DataValueField="ReoccuranceId" SelectedValue='<%#
> Bind("ReoccuranceId") %>'>
> </aspropDownList>
> </EditItemTemplate>
> <InsertItemTemplate>
> <aspropDownList ID="DropDownList3" runat="server"
> DataSourceID="sdsReoccur" DataTextField="Reoccurance"
> DataValueField="ReoccuranceId" SelectedValue='<%#
> Bind("ReoccuranceId") %>'>
> </aspropDownList>
> </InsertItemTemplate>
> <ItemTemplate>
> <asp:Label ID="Label4" runat="server" Text='<%#
> Bind("Reoccurance") %>'></asp:Label>
> </ItemTemplate>
> </asp:TemplateField>
> <asp:BoundField DataField="Comments" HeaderText="Comments"
> SortExpression="Comments" >
> <ItemStyle Width="300px" />
> </asp:BoundField>
> <asp:CommandField ShowEditButton="True" ShowInsertButton="True"
> />
> </Fields>
> <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"
> />
> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
> </aspetailsView>
>
>
> <asp:SqlDataSource ID="sdsProgramDetails" runat="server"
> ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
> DeleteCommand="DELETE FROM [Programs] WHERE
> [ProgramId] = @ProgramId" InsertCommand="INSERT INTO [Programs]
> ([ProgramTypeId], [ProgramName], [ActiveProgram], [MaxClients],
> [StartDate], [DefaultMgmtFee], [MgmtFeeType], [Comments]) VALUES
> (@ProgramTypeId, @ProgramName, @ActiveProgram, @MaxClients, @StartDate,
> @DefaultMgmtFee, @MgmtFeeType, @Comments)"
> SelectCommand="SELECT Programs.ProgramId,
> Programs.ProgramTypeId, Programs.ProgramName, Programs.ActiveProgram,
> Programs.MaxClients, Programs.StartDate, Programs.DefaultMgmtFee,
> Programs.MgmtFeeType, Programs.Comments, ProgramTypes.ProgramType,
> Programs.ReoccuranceNumber, Programs.ReoccuranceId,
> Reoccurance.Reoccurance FROM Programs INNER JOIN ProgramTypes ON
> Programs.ProgramTypeId = ProgramTypes.ProgramTypeId INNER JOIN Reoccurance
> ON Programs.ReoccuranceId = Reoccurance.ReoccuranceId WHERE
> (Programs.ProgramId = @ProgramId)" UpdateCommand="UPDATE [Programs] SET
> [ProgramTypeId] = @ProgramTypeId, [ProgramName] = @ProgramName,
> [ActiveProgram] = @ActiveProgram, [MaxClients] = @MaxClients, [StartDate]
> = @StartDate, [DefaultMgmtFee] = @DefaultMgmtFee, [MgmtFeeType] =
> @MgmtFeeType, [Comments] = @Comments WHERE [ProgramId] = @ProgramId">
> <DeleteParameters>
> <asparameter Name="ProgramId"
> Type="Int32" />
> </DeleteParameters>
> <UpdateParameters>
> <asparameter Name="ProgramTypeId"
> Type="Int32" />
> <asparameter Name="ProgramName"
> Type="String" />
> <asparameter Name="ActiveProgram"
> Type="Boolean" />
> <asparameter Name="MaxClients"
> Type="Int32" />
> <asparameter Name="StartDate"
> Type="DateTime" />
> <asparameter Name="DefaultMgmtFee"
> Type="Decimal" />
> <asparameter Name="MgmtFeeType"
> Type="String" />
> <asparameter Name="Comments"
> Type="String" />
> <asparameter Name="ProgramId"
> Type="Int32" />
> </UpdateParameters>
> <SelectParameters>
> <asp:ControlParameter ControlID="GridView1"
> Name="ProgramId" PropertyName="SelectedValue"
> Type="Int32" />
> </SelectParameters>
> <InsertParameters>
> <asparameter Name="ProgramTypeId"
> Type="Int32" />
> <asparameter Name="ProgramName"
> Type="String" />
> <asparameter Name="ActiveProgram"
> Type="Boolean" />
> <asparameter Name="MaxClients"
> Type="Int32" />
> <asparameter Name="StartDate"
> Type="DateTime" />
> <asparameter Name="DefaultMgmtFee"
> Type="Decimal" />
> <asparameter Name="MgmtFeeType"
> Type="String" />
> <asparameter Name="Comments"
> Type="String" />
> </InsertParameters>
> </asp:SqlDataSource>
>



 
Reply With Quote
 
 
 
 
VB Programmer
Guest
Posts: n/a
 
      10-09-2007
I appreciate your help!

"Eliyahu Goldin" <> wrote in
message news:%...
> Your datasources are linked correctly. You need to handle the gridview's
> SelectedIndexChanged event like this:
>
> protected void GridView1_OnSelectedIndexChanged(Object sender, EventArgs
> e)
>
> {
>
> this.sdsProgramDetails.Select(System.Web.UI.DataSo urceSelectArguments.Empty);
>
> this.DetailsView1.DataBind();
>
> }
>
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
>
> "VB Programmer" <> wrote in message
> news:%...
>> For some reason, when I select the record in my GridView the DetailsView
>> doesn't show up anymore. What "links" the 2?
>>
>> The DetailsView is based on an SQLDataSource with a WHERE clause using
>> the value from the GridView.
>>
>> Any ideas?
>>
>> Here's the definitions...
>>
>> <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
>> AllowSorting="True"
>> AutoGenerateColumns="False" CellPadding="4"
>> DataSourceID="SqlDataSource1" ForeColor="#333333"
>> GridLines="None" DataKeyNames="ProgramId">
>> <FooterStyle BackColor="#5D7B9D" Font-Bold="True"
>> ForeColor="White" />
>> <Columns>
>> <asp:CommandField ShowSelectButton="True" />
>> <asp:BoundField DataField="ProgramName" HeaderText="Program"
>> SortExpression="ProgramName">
>> <ItemStyle Width="200px" />
>> </asp:BoundField>
>> <asp:BoundField DataField="ProgramId" HeaderText="ProgramId"
>> InsertVisible="False"
>> ReadOnly="True" SortExpression="ProgramId" Visible="False"
>> />
>> <asp:TemplateField>
>> <ItemTemplate>
>> <asp:LinkButton runat="server" ID="btnDelete"
>> CommandName="Delete" OnClientClick="return confirm('Are you sure you want
>> to PERMANENTLY DELETE this record and ALL associated records?');"
>> Text="Delete"></asp:LinkButton>
>> </ItemTemplate>
>> </asp:TemplateField>
>> </Columns>
>> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
>> <EditRowStyle BackColor="#999999" />
>> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
>> ForeColor="#333333" />
>> <PagerStyle BackColor="#284775" ForeColor="White"
>> HorizontalAlign="Center" />
>> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
>> ForeColor="White" />
>> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
>> </asp:GridView>
>>
>> <aspetailsView ID="DetailsView1" runat="server"
>> AutoGenerateRows="False" CellPadding="4"
>> DataKeyNames="ProgramId" DataSourceID="sdsProgramDetails"
>> ForeColor="#333333" GridLines="None"
>> Height="50px" Width="465px">
>> <FooterStyle BackColor="#5D7B9D" Font-Bold="True"
>> ForeColor="White" />
>> <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
>> <EditRowStyle BackColor="#999999" />
>> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
>> <PagerStyle BackColor="#284775" ForeColor="White"
>> HorizontalAlign="Center" />
>> <Fields>
>> <asp:BoundField DataField="ProgramName" HeaderText="Program
>> Name" SortExpression="ProgramName" />
>> <asp:CheckBoxField DataField="ActiveProgram"
>> HeaderText="Active" SortExpression="ActiveProgram" />
>> <asp:BoundField DataField="ProgramId" HeaderText="ProgramId"
>> InsertVisible="False"
>> ReadOnly="True" SortExpression="ProgramId" Visible="False"
>> />
>> <asp:TemplateField HeaderText="Program Type"
>> SortExpression="ProgramTypeId">
>> <EditItemTemplate>
>> <aspropDownList ID="DropDownList1" runat="server"
>> DataSourceID="sdsProgTypes" DataTextField="ProgramType"
>> DataValueField="ProgramTypeId" SelectedValue='<%#
>> Bind("ProgramTypeId") %>' Width="269px">
>> </aspropDownList>
>> </EditItemTemplate>
>> <InsertItemTemplate>
>> <aspropDownList ID="DropDownList1" runat="server"
>> DataSourceID="sdsProgTypes" DataTextField="ProgramType"
>> DataValueField="ProgramTypeId" SelectedValue='<%#
>> Bind("ProgramTypeId") %>' Width="269px">
>> </aspropDownList>
>> </InsertItemTemplate>
>> <ItemTemplate>
>> <asp:Label ID="Label2" runat="server" Text='<%#
>> Bind("ProgramType") %>'></asp:Label>
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:BoundField DataField="MaxClients" HeaderText="Max
>> Clients" SortExpression="MaxClients" />
>> <asp:TemplateField HeaderText="Start Date"
>> SortExpression="StartDate">
>> <EditItemTemplate>
>> <asp:Calendar ID="Calendar1" runat="server"
>> BackColor="White" BorderColor="White"
>> BorderWidth="1px" Font-Names="Verdana"
>> Font-Size="9pt" ForeColor="Black" Height="170px"
>> NextPrevFormat="FullMonth" SelectedDate='<%#
>> Bind("StartDate") %>' Width="274px">
>> <SelectedDayStyle BackColor="#333399"
>> ForeColor="White" />
>> <TodayDayStyle BackColor="#CCCCCC" />
>> <OtherMonthDayStyle ForeColor="#999999" />
>> <NextPrevStyle Font-Bold="True" Font-Size="8pt"
>> ForeColor="#333333" VerticalAlign="Bottom" />
>> <DayHeaderStyle Font-Bold="True" Font-Size="8pt"
>> />
>> <TitleStyle BackColor="White" BorderColor="Black"
>> BorderWidth="4px" Font-Bold="True"
>> Font-Size="12pt" ForeColor="#333399" />
>> </asp:Calendar>
>> </EditItemTemplate>
>> <InsertItemTemplate>
>> <asp:Calendar ID="Calendar1" runat="server"
>> BackColor="White" BorderColor="White"
>> BorderWidth="1px" Font-Names="Verdana"
>> Font-Size="9pt" ForeColor="Black" Height="170px"
>> NextPrevFormat="FullMonth" SelectedDate='<%#
>> Bind("StartDate") %>' Width="274px">
>> <SelectedDayStyle BackColor="#333399"
>> ForeColor="White" />
>> <TodayDayStyle BackColor="#CCCCCC" />
>> <OtherMonthDayStyle ForeColor="#999999" />
>> <NextPrevStyle Font-Bold="True" Font-Size="8pt"
>> ForeColor="#333333" VerticalAlign="Bottom" />
>> <DayHeaderStyle Font-Bold="True" Font-Size="8pt"
>> />
>> <TitleStyle BackColor="White" BorderColor="Black"
>> BorderWidth="4px" Font-Bold="True"
>> Font-Size="12pt" ForeColor="#333399" />
>> </asp:Calendar>
>> </InsertItemTemplate>
>> <ItemTemplate>
>> <asp:Label ID="Label3" runat="server" Text='<%#
>> Bind("StartDate", "{0:d}") %>'></asp:Label>
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:BoundField DataField="DefaultMgmtFee" HeaderText="Default
>> Mgmt Fee" SortExpression="DefaultMgmtFee" />
>> <asp:TemplateField HeaderText="Fee Type"
>> SortExpression="MgmtFeeType">
>> <EditItemTemplate>
>> <aspropDownList ID="DropDownList2" runat="server"
>> SelectedValue='<%# Bind("MgmtFeeType") %>'>
>> <asp:ListItem>%</asp:ListItem>
>> <asp:ListItem>$</asp:ListItem>
>> </aspropDownList>
>> </EditItemTemplate>
>> <InsertItemTemplate>
>> <aspropDownList ID="DropDownList2" runat="server"
>> SelectedValue='<%# Bind("MgmtFeeType") %>'>
>> <asp:ListItem>%</asp:ListItem>
>> <asp:ListItem>$</asp:ListItem>
>> </aspropDownList>
>> </InsertItemTemplate>
>> <ItemTemplate>
>> <asp:Label ID="Label1" runat="server" Text='<%#
>> Bind("MgmtFeeType") %>'></asp:Label>
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:BoundField DataField="ReoccuranceNumber"
>> HeaderText="Reoccur #" SortExpression="ReoccuranceNumber" />
>> <asp:TemplateField HeaderText="Reoccur Interval"
>> SortExpression="Reoccurance">
>> <EditItemTemplate>
>> <aspropDownList ID="DropDownList3" runat="server"
>> DataSourceID="sdsReoccur" DataTextField="Reoccurance"
>> DataValueField="ReoccuranceId" SelectedValue='<%#
>> Bind("ReoccuranceId") %>'>
>> </aspropDownList>
>> </EditItemTemplate>
>> <InsertItemTemplate>
>> <aspropDownList ID="DropDownList3" runat="server"
>> DataSourceID="sdsReoccur" DataTextField="Reoccurance"
>> DataValueField="ReoccuranceId" SelectedValue='<%#
>> Bind("ReoccuranceId") %>'>
>> </aspropDownList>
>> </InsertItemTemplate>
>> <ItemTemplate>
>> <asp:Label ID="Label4" runat="server" Text='<%#
>> Bind("Reoccurance") %>'></asp:Label>
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:BoundField DataField="Comments" HeaderText="Comments"
>> SortExpression="Comments" >
>> <ItemStyle Width="300px" />
>> </asp:BoundField>
>> <asp:CommandField ShowEditButton="True"
>> ShowInsertButton="True" />
>> </Fields>
>> <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
>> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
>> ForeColor="White" />
>> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
>> </aspetailsView>
>>
>>
>> <asp:SqlDataSource ID="sdsProgramDetails" runat="server"
>> ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
>> DeleteCommand="DELETE FROM [Programs] WHERE
>> [ProgramId] = @ProgramId" InsertCommand="INSERT INTO [Programs]
>> ([ProgramTypeId], [ProgramName], [ActiveProgram], [MaxClients],
>> [StartDate], [DefaultMgmtFee], [MgmtFeeType], [Comments]) VALUES
>> (@ProgramTypeId, @ProgramName, @ActiveProgram, @MaxClients, @StartDate,
>> @DefaultMgmtFee, @MgmtFeeType, @Comments)"
>> SelectCommand="SELECT Programs.ProgramId,
>> Programs.ProgramTypeId, Programs.ProgramName, Programs.ActiveProgram,
>> Programs.MaxClients, Programs.StartDate, Programs.DefaultMgmtFee,
>> Programs.MgmtFeeType, Programs.Comments, ProgramTypes.ProgramType,
>> Programs.ReoccuranceNumber, Programs.ReoccuranceId,
>> Reoccurance.Reoccurance FROM Programs INNER JOIN ProgramTypes ON
>> Programs.ProgramTypeId = ProgramTypes.ProgramTypeId INNER JOIN
>> Reoccurance ON Programs.ReoccuranceId = Reoccurance.ReoccuranceId WHERE
>> (Programs.ProgramId = @ProgramId)" UpdateCommand="UPDATE [Programs] SET
>> [ProgramTypeId] = @ProgramTypeId, [ProgramName] = @ProgramName,
>> [ActiveProgram] = @ActiveProgram, [MaxClients] = @MaxClients, [StartDate]
>> = @StartDate, [DefaultMgmtFee] = @DefaultMgmtFee, [MgmtFeeType] =
>> @MgmtFeeType, [Comments] = @Comments WHERE [ProgramId] = @ProgramId">
>> <DeleteParameters>
>> <asparameter Name="ProgramId"
>> Type="Int32" />
>> </DeleteParameters>
>> <UpdateParameters>
>> <asparameter Name="ProgramTypeId"
>> Type="Int32" />
>> <asparameter Name="ProgramName"
>> Type="String" />
>> <asparameter Name="ActiveProgram"
>> Type="Boolean" />
>> <asparameter Name="MaxClients"
>> Type="Int32" />
>> <asparameter Name="StartDate"
>> Type="DateTime" />
>> <asparameter Name="DefaultMgmtFee"
>> Type="Decimal" />
>> <asparameter Name="MgmtFeeType"
>> Type="String" />
>> <asparameter Name="Comments"
>> Type="String" />
>> <asparameter Name="ProgramId"
>> Type="Int32" />
>> </UpdateParameters>
>> <SelectParameters>
>> <asp:ControlParameter
>> ControlID="GridView1" Name="ProgramId" PropertyName="SelectedValue"
>> Type="Int32" />
>> </SelectParameters>
>> <InsertParameters>
>> <asparameter Name="ProgramTypeId"
>> Type="Int32" />
>> <asparameter Name="ProgramName"
>> Type="String" />
>> <asparameter Name="ActiveProgram"
>> Type="Boolean" />
>> <asparameter Name="MaxClients"
>> Type="Int32" />
>> <asparameter Name="StartDate"
>> Type="DateTime" />
>> <asparameter Name="DefaultMgmtFee"
>> Type="Decimal" />
>> <asparameter Name="MgmtFeeType"
>> Type="String" />
>> <asparameter Name="Comments"
>> Type="String" />
>> </InsertParameters>
>> </asp:SqlDataSource>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Missing Enable Editing checkbox in GridView and DetailsView K B ASP .Net 1 04-19-2006 06:54 PM
Gridview and Detailsview "New" record Giorgio ASP .Net 1 03-15-2006 11:33 AM
DetailsView - Changing to Insert Mode (Not By Using the Insert Button In the DetailsView Control) Feege ASP .Net Web Controls 0 12-20-2005 12:28 AM
RE: Link Link Link =?Utf-8?B?REw=?= Windows 64bit 0 05-17-2005 12:15 PM
Re: Link Link Link DANGER WILL ROBINSON!!! Kevin Spencer ASP .Net 0 05-17-2005 10:41 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57