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 :)
No comments:
Post a Comment