"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Wednesday, May 12, 2010

generate serial number for the rows in datagrid

To generate auto number for the rows in datagrid we can use the following code in ItemDataBound event.


private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
   if(e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
   {
     e.Item.Cells[0].Text=e.Item.ItemIndex.ToString();
   }
}


Have a nice day... 'N happy Coding :)
 Need For Speed CarbonNeed for Speed Carbon Collector's EditionNeed for Speed: Hot Pursuit 2

No comments: