Autonumbering in Datagrid

  • Thread starter Thread starter BlueHeaven
  • Start date Start date
B

BlueHeaven

Hi all, How to create auto numbering in datagrid if I
show the data from database to datagrid by
using datasource = dataset.

Thanks all
 
Try using the OnItemDataBound event

For each item in the dataset, you can increment an integer by 1 and diplay
the result in a label in the datagrid

i.e.

int i = 0;

private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)

{

i++;

e.Item.FindControl["lbl2"].Text = i.ToString();

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top