A gridview event/method to capture all checkbox.check states in this BoundColumn and Item_Bound grid

H

hazz

The following code generates checkbox values from the database. Once the
user selects/deselects checkbox values, is there a way to obtain the ID and
Checkbox.Checked state from these BoundColumns so I can update the table
they came from? Thank you. -Greg

<asp:DataGrid id="ItemsGrid" runat="server"
OnItemDataBound="Item_Bound" AutoGenerateColumns="False"
AllowSorting="True">
<Columns>
<asp:BoundColumn HeaderText="ID"
ReadOnly="True"
DataField="ID"/>
<asp:BoundColumn HeaderText="Column_Name"
ReadOnly="True"
DataField="ColumnName"/>

<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1"
Text=""
runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>

void Item_Bound(Object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
CheckBox check = (CheckBox)e.Item.FindControl("CheckBox1");
if (check != null)
{
check.Checked =
Convert.ToBoolean(((SSI.ColumnsForReport)(e.Item.DataItem)).Include_in_Report);
}
}
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top