Hi neehakale,
To add a checkbox control in your datagrid.
1. Right click on your datagrid
2. Go to property builder
3. Select columns
4. In the Available columns box, select Template Column
5. After adding, click Ok Button.
6. Right click again on your datagrid but this time select Edit template
7. You will see that there is column(0).
8. In the item template, drag and drop a check box control.
9. after adding the check box control. right click again then select End Template Editing.
10. Your done adding a checkbox.
11. if you want to go back.. just follow the same procedure.
assuming the name of your checkbox control is CheckBox1
and your datagrid name is DataGrid1
please create a button named btnCheckedItems..
in the click event of this button.. you place the code below
this program will identify if there are checked items and perform any action.
private void btnCheckedItems_Click(object sender, System.EventArgs e)
{
//identify if there are checked items here
int NoOfCheckedItems=0;
foreach (DataGridItem i in DataGrid1.Items)
{
CheckBox ItemsChecked = (CheckBox) i.FindControl ("CheckBox1");
if (ItemsChecked.Checked)
{
NoOfCheckedItems +=1;
//retrieve/check the current value of the selected item
Response.Write(i.Cells[1].Text);
}
}
Response.Write(NoOfCheckedItems);
}
I hope this will help you.
Best Regards,
Ruel
YM ID:uelskies@yahoo.com
I am doing an application where i need to select some data from the grid,to select the data from the grid ,each and every row and column data should come with some selection control..m using checkbox here..so can ny body of u know how to pass checkboxes to the datagrid,so that we can select tha data from the grid....its urgent pls rp soon