GridView unbound checkbox state

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>
 
L

Livetecs

You will be required to play with session in order to keep changes between
page navigation. For example, you can keep datatable in session which you
are using for binding here. And then you can update gridview values in
session datatable before navigation to other page.

Develoepr:TimeLive and billing application
Web based ASP.Net Timesheet (US$ 300 / unlimited users)
Source Code: US$ 500
http://www.livetecs.com
 
D

David C

That seems like a lot of work. So every time they click on a new page number
I have to check to see if the 10 records I am about to display are already
selected?

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top