V
VB Programmer
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>
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>