datagrid| control//Create handle delegate
private void Dgorderconfirm_itemcreated (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.item.itemtype==listitemtype.item| | E.item.itemtype==listitemtype.alternatingitem)
{
CheckBox cb= (checkbox) E.item.findcontrol ("Cbselect");
Cb. Checkedchanged+=new System.EventHandler (this.cbselectchanged);
}
}
Creating events
private void Cbselectchanged (Object Sender,system.eventargs e)
{
CheckBox cb= (checkbox) sender;
DataGridItem li= (DataGridItem) CB. Parent.parent;
if (CB). Checked==true)
{
Li. CELLS[8]. Text=string. Format (' {0:f2} ', float. Parse (li. CELLS[7]. Text) * (float. Parse ((TextBox) li. FindControl ("Tbdiscount")). Text)). ToString ();
This.lbgetsum.text=string. Format (' {0:f2} ', float. Parse (This.lbgetsum.Text) +float. Parse (li. CELLS[8]. Text)). ToString ();
}
Else
{
This.lbgetsum.text=string. Format (' {0:f2} ', float. Parse (This.lbgetsum.Text)-float. Parse (li. CELLS[8]. Text)). ToString ();
Li. CELLS[8]. Text= "";
}
}
Traversing the DataGrid
foreach (DataGridItem dgi in Datagrid1.items)
{
if ((CheckBox) Dgi. FindControl ("Cbselect")). Checked && ((CheckBox) Dgi. FindControl ("Cbback")). Checked))
{
Response.Write (String. Format ("<script language= ' javascript ' >alert (\" Can not receive and withdraw a list are both selected \ ");</script>));
Return
}
}