To add a CheckBox control column for the DataGrid space, you first need to add a template column to the DataGrid control and then add a CheckBox control to the template column
There is a DataGridItem class in the System.Web.UI.WebControls namespace that represents the items in the DataGrid control. There is a FindControl method in the class that searches the current naming container for a server control with the specified ID parameter, using the following method:
Public virtual control FindControl (string id);
Parameters: ID to find the identity value of the control
Return value: Returns the control if the specified control exists, or returns an empty if it does not exist
Click event for the Get Selected item button (Example of adding a CheckBox control column in the DataGrid control)
private void Renamefolder_click (object sender, System.Web.UI.ImageClickEventArgs e)
{
System.Web.UI.WebControls.CheckBox CheckBox1;
String ID;
System.Text.StringBuilder strmsg=new System.Text.StringBuilder ("fname field values for selected items are: foreach (DataGridItem odatagriditem in Datagrid1.items)
{
checkbox1= (checkbox) Odatagriditem.findcontrol ("CheckBox1");
if (CheckBox1. Checked)
{
Id= ((HyperLink) (Odatagriditem.findcontrol ("HyperLink1")). Text;
strmsg. Append (id+ "<br>}
Message.text=strmsg. ToString ();
}
}