Click here to Skip to main content
15,886,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have Datagrid in asp.net page with the below mentioned data

Device Name Column 1 Column 2
-------------------------------------------
iPad Check Box Check Box
iPhone Check Box Check Box
iStore Check Box Check Box


Here Check box is – Check Box Control on each Cell, please note that these check boxes are generating dynamically, initially in design mode there won't be any check box event

Here Device_Name,Column1 and Column2 are column names, under these columns we have check boxes on both the columns, Please can anybody help me how do I we get to know which all the check box's are TICKED.

Once it has been TICKED I want to assign checked value (just to identify which are been ticked) to array list from Grid view (for storing purpose, later I will pass this array list to next page).
Could you please someone help me one this
Please Note that: - while creating Gridview initially Check box will not be having any Id’s because those check boxes are dynamically generated.
This is my C# code for creating dynamic Check boxes in Gridview :-
protected void GrdOSInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 1; i < 3; i++)
{
//foreach (GridView row in GridView1.Rows)
//{
CheckBox chk = new CheckBox();
chk.EnableViewState = true;
chk.Enabled = true;
chk.ID = "chkb"+i;

e.Row.Cells[i].Controls.Add(chk);
//}
}
}
}

This is my asp.net code
<asp:GridView ID="GrdOSInfo" runat="server" CssClass="grid_table"
onrowdatabound="GrdOSInfo_RowDataBound" BackColor="White" Width="200px"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical"
>

<footerstyle backcolor="#CCCCCC" forecolor="Black">
<HeaderStyle CssClass="grid_head_row" Font-Bold="true" ForeColor="White"
BackColor="#000084" />
<pagerstyle cssclass="paging" backcolor="#999999" forecolor="Black">
HorizontalAlign="Center" />
<rowstyle cssclass="grid_even_row" backcolor="#EEEEEE" forecolor="Black">
<alternatingrowstyle cssclass="grid_even_row" backcolor="#DCDCDC">
<SelectedRowStyle CssClass="grid_head_row" BackColor="#008A8C" Font-Bold="True"
ForeColor="White" />
<sortedascendingcellstyle backcolor="#F1F1F1">
<sortedascendingheaderstyle backcolor="#0000A9">
<sorteddescendingcellstyle backcolor="#CAC9C9">
<sorteddescendingheaderstyle backcolor="#000065">
Posted
Comments
shankar01021981 3-Aug-14 8:22am    
Can any one please help me for my Check box problem ?
j snooze 5-Aug-14 17:33pm    
You will eventually need those checkbox ID's even though they are dynamically generated, you are still giving them a unique ID. You can get them from the request form Request.Form["chkb1"].
They might only come acrossed if they are checked. I think checkboxes are weird like that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900