![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 asp etailsView 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 asp ropDownList ID="DropDownList1" runat="server"DataSourceID="sdsProgTypes" DataTextField="ProgramType" DataValueField="ProgramTypeId" SelectedValue='<%# Bind("ProgramTypeId") %>' Width="269px" /asp ropDownList/EditItemTemplate InsertItemTemplate asp ropDownList ID="DropDownList1" runat="server"DataSourceID="sdsProgTypes" DataTextField="ProgramType" DataValueField="ProgramTypeId" SelectedValue='<%# Bind("ProgramTypeId") %>' Width="269px" /asp ropDownList/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 asp ropDownList ID="DropDownList2" runat="server"SelectedValue='<%# Bind("MgmtFeeType") %>' asp:ListItem>%</asp:ListItem asp:ListItem>$</asp:ListItem /asp ropDownList/EditItemTemplate InsertItemTemplate asp ropDownList ID="DropDownList2" runat="server"SelectedValue='<%# Bind("MgmtFeeType") %>' asp:ListItem>%</asp:ListItem asp:ListItem>$</asp:ListItem /asp ropDownList/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 asp ropDownList ID="DropDownList3" runat="server"DataSourceID="sdsReoccur" DataTextField="Reoccurance" DataValueField="ReoccuranceId" SelectedValue='<%# Bind("ReoccuranceId") %>' /asp ropDownList/EditItemTemplate InsertItemTemplate asp ropDownList ID="DropDownList3" runat="server"DataSourceID="sdsReoccur" DataTextField="Reoccurance" DataValueField="ReoccuranceId" SelectedValue='<%# Bind("ReoccuranceId") %>' /asp ropDownList/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" / /asp etailsViewasp: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 asp:Parameter Name="ProgramId" Type="Int32" / /DeleteParameters UpdateParameters asp:Parameter Name="ProgramTypeId" Type="Int32" / asp:Parameter Name="ProgramName" Type="String" / asp:Parameter Name="ActiveProgram" Type="Boolean" / asp:Parameter Name="MaxClients" Type="Int32" / asp:Parameter Name="StartDate" Type="DateTime" / asp:Parameter Name="DefaultMgmtFee" Type="Decimal" / asp:Parameter Name="MgmtFeeType" Type="String" / asp:Parameter Name="Comments" Type="String" / asp:Parameter Name="ProgramId" Type="Int32" / /UpdateParameters SelectParameters asp:ControlParameter ControlID="GridView1" Name="ProgramId" PropertyName="SelectedValue" Type="Int32" / /SelectParameters InsertParameters asp:Parameter Name="ProgramTypeId" Type="Int32" / asp:Parameter Name="ProgramName" Type="String" / asp:Parameter Name="ActiveProgram" Type="Boolean" / asp:Parameter Name="MaxClients" Type="Int32" / asp:Parameter Name="StartDate" Type="DateTime" / asp:Parameter Name="DefaultMgmtFee" Type="Decimal" / asp:Parameter Name="MgmtFeeType" Type="String" / asp:Parameter Name="Comments" Type="String" / /InsertParameters /asp:SqlDataSource |
#3
| |||
| |||
|
|
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" <donotemailme (AT) somewhere (DOT) com> wrote in message news:%23lf3mvcCIHA.1188 (AT) TK2MSFTNGP04 (DOT) phx.gbl... 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 asp etailsView 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 asp ropDownList ID="DropDownList1" runat="server"DataSourceID="sdsProgTypes" DataTextField="ProgramType" DataValueField="ProgramTypeId" SelectedValue='<%# Bind("ProgramTypeId") %>' Width="269px" /asp ropDownList/EditItemTemplate InsertItemTemplate asp ropDownList ID="DropDownList1" runat="server"DataSourceID="sdsProgTypes" DataTextField="ProgramType" DataValueField="ProgramTypeId" SelectedValue='<%# Bind("ProgramTypeId") %>' Width="269px" /asp ropDownList/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 asp ropDownList ID="DropDownList2" runat="server"SelectedValue='<%# Bind("MgmtFeeType") %>' asp:ListItem>%</asp:ListItem asp:ListItem>$</asp:ListItem /asp ropDownList/EditItemTemplate InsertItemTemplate asp ropDownList ID="DropDownList2" runat="server"SelectedValue='<%# Bind("MgmtFeeType") %>' asp:ListItem>%</asp:ListItem asp:ListItem>$</asp:ListItem /asp ropDownList/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 asp ropDownList ID="DropDownList3" runat="server"DataSourceID="sdsReoccur" DataTextField="Reoccurance" DataValueField="ReoccuranceId" SelectedValue='<%# Bind("ReoccuranceId") %>' /asp ropDownList/EditItemTemplate InsertItemTemplate asp ropDownList ID="DropDownList3" runat="server"DataSourceID="sdsReoccur" DataTextField="Reoccurance" DataValueField="ReoccuranceId" SelectedValue='<%# Bind("ReoccuranceId") %>' /asp ropDownList/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" / /asp etailsViewasp: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 asp:Parameter Name="ProgramId" Type="Int32" / /DeleteParameters UpdateParameters asp:Parameter Name="ProgramTypeId" Type="Int32" / asp:Parameter Name="ProgramName" Type="String" / asp:Parameter Name="ActiveProgram" Type="Boolean" / asp:Parameter Name="MaxClients" Type="Int32" / asp:Parameter Name="StartDate" Type="DateTime" / asp:Parameter Name="DefaultMgmtFee" Type="Decimal" / asp:Parameter Name="MgmtFeeType" Type="String" / asp:Parameter Name="Comments" Type="String" / asp:Parameter Name="ProgramId" Type="Int32" / /UpdateParameters SelectParameters asp:ControlParameter ControlID="GridView1" Name="ProgramId" PropertyName="SelectedValue" Type="Int32" / /SelectParameters InsertParameters asp:Parameter Name="ProgramTypeId" Type="Int32" / asp:Parameter Name="ProgramName" Type="String" / asp:Parameter Name="ActiveProgram" Type="Boolean" / asp:Parameter Name="MaxClients" Type="Int32" / asp:Parameter Name="StartDate" Type="DateTime" / asp:Parameter Name="DefaultMgmtFee" Type="Decimal" / asp:Parameter Name="MgmtFeeType" Type="String" / asp:Parameter Name="Comments" Type="String" / /InsertParameters /asp:SqlDataSource |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |