D
David C
I have a GridView that is bound to a datasource but one column has an
unbound checkbox to use for selections for emailing. The GridView also has
paging set to 10 rows per page and the datasource table has approx. 400
records that I want to randomly select. I have everything working ok,
except that when I hit the next page link I lose all the checked values. Is
there any way to retain them between postbacks? I though of adding a column
to the database table but then I would have to "Edit" each row that I want
to check. Any help or direction would be greatly appreciated.
-David
p.s. below is my GridView if it helps
<asp:GridView ID="gvOrgInfo" runat="server"
AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="OrgID" DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display."
ForeColor="#333333" GridLines="None" AllowPaging="True"
AllowSorting="True" OnRowDataBound="gvOrgInfo_RowDataBound" PageSize="3">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="ckSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="OrgID" HeaderText="OrgID"
ReadOnly="True" SortExpression="OrgID" Visible="False" />
<asp:TemplateField HeaderText="Organization"
SortExpression="Organization">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("Organization") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("Organization") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="OrgContact" HeaderText="Contact"
SortExpression="OrgContact" />
<asp:TemplateField HeaderText="Email"
SortExpression="OrgEmail">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%#
Bind("OrgEmail") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:HyperLink ID="HLOrgEmail" runat="server"
Text='<%# Bind("OrgEmail") %>'
NavigateUrl='<%#DataBinder.Eval(Container,"DataItem.OrgEmail","MAILTO:{0}")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="OrgAddress" HeaderText="Address1"
/>
<asp:BoundField DataField="OrgAddress2"
HeaderText="Address2" />
<asp:BoundField DataField="OrgCity" HeaderText="City"
SortExpression="OrgCity" />
<asp:BoundField DataField="OrgState" HeaderText="State"
SortExpression="OrgState" />
<asp:BoundField DataField="OrgCountry" HeaderText="Country"
SortExpression="OrgCountry" />
<asp:BoundField DataField="OrgPostalCode" HeaderText="Postal
Code" SortExpression="OrgPostalCode" />
<asp:BoundField DataField="OrgPhone" HeaderText="Phone" />
<asp:BoundField DataField="OrgUserName" HeaderText="User
Name" SortExpression="OrgUserName" />
<asp:BoundField DataField="OrgPword" HeaderText="Password"
SortExpression="OrgPword" />
<asp:BoundField DataField="OrgIDSHS" HeaderText="SHS OrgID"
SortExpression="OrgIDSHS" />
<asp:CheckBoxField DataField="Admin" HeaderText="Admin"
SortExpression="Admin" />
<asp:BoundField DataField="LastLogon" HeaderText="Last
Logon" SortExpression="LastLogon" DataFormatString="{0:d}" />
<asp:BoundField DataField="Expiration"
HeaderText="Expiration" SortExpression="Expiration" DataFormatString="{0:d}"
/>
<asp:BoundField DataField="LogoFileName"
HeaderText="LogoFileName" SortExpression="LogoFileName" Visible="False" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="LemonChiffon" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
unbound checkbox to use for selections for emailing. The GridView also has
paging set to 10 rows per page and the datasource table has approx. 400
records that I want to randomly select. I have everything working ok,
except that when I hit the next page link I lose all the checked values. Is
there any way to retain them between postbacks? I though of adding a column
to the database table but then I would have to "Edit" each row that I want
to check. Any help or direction would be greatly appreciated.
-David
p.s. below is my GridView if it helps
<asp:GridView ID="gvOrgInfo" runat="server"
AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="OrgID" DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display."
ForeColor="#333333" GridLines="None" AllowPaging="True"
AllowSorting="True" OnRowDataBound="gvOrgInfo_RowDataBound" PageSize="3">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="ckSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="OrgID" HeaderText="OrgID"
ReadOnly="True" SortExpression="OrgID" Visible="False" />
<asp:TemplateField HeaderText="Organization"
SortExpression="Organization">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("Organization") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("Organization") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="OrgContact" HeaderText="Contact"
SortExpression="OrgContact" />
<asp:TemplateField HeaderText="Email"
SortExpression="OrgEmail">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%#
Bind("OrgEmail") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:HyperLink ID="HLOrgEmail" runat="server"
Text='<%# Bind("OrgEmail") %>'
NavigateUrl='<%#DataBinder.Eval(Container,"DataItem.OrgEmail","MAILTO:{0}")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="OrgAddress" HeaderText="Address1"
/>
<asp:BoundField DataField="OrgAddress2"
HeaderText="Address2" />
<asp:BoundField DataField="OrgCity" HeaderText="City"
SortExpression="OrgCity" />
<asp:BoundField DataField="OrgState" HeaderText="State"
SortExpression="OrgState" />
<asp:BoundField DataField="OrgCountry" HeaderText="Country"
SortExpression="OrgCountry" />
<asp:BoundField DataField="OrgPostalCode" HeaderText="Postal
Code" SortExpression="OrgPostalCode" />
<asp:BoundField DataField="OrgPhone" HeaderText="Phone" />
<asp:BoundField DataField="OrgUserName" HeaderText="User
Name" SortExpression="OrgUserName" />
<asp:BoundField DataField="OrgPword" HeaderText="Password"
SortExpression="OrgPword" />
<asp:BoundField DataField="OrgIDSHS" HeaderText="SHS OrgID"
SortExpression="OrgIDSHS" />
<asp:CheckBoxField DataField="Admin" HeaderText="Admin"
SortExpression="Admin" />
<asp:BoundField DataField="LastLogon" HeaderText="Last
Logon" SortExpression="LastLogon" DataFormatString="{0:d}" />
<asp:BoundField DataField="Expiration"
HeaderText="Expiration" SortExpression="Expiration" DataFormatString="{0:d}"
/>
<asp:BoundField DataField="LogoFileName"
HeaderText="LogoFileName" SortExpression="LogoFileName" Visible="False" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<EditRowStyle BackColor="LemonChiffon" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>