C# – Gridview : Row number for Inner grid

asp.netcgridview

In my page im using gridview to display records. Each row having record in the inner grid.
i want to display row number for the inner grid, for each row inner grid row number should start with 1.pls help me

It's a Web application (.NET 2008 , .NET 3.5 + C#)

Best Answer

DataGridViewTextBoxCell newCell = new DataGridViewTextBoxCell();
DataGridViewColumn SNOCol = new DataGridViewColumn(newCell);
SNOCol.DisplayIndex = 0;
SNOCol.HeaderText = "SNO";
SNOCol.Name = "SNO";
DataGridView1.Columns.Add(SNOCol);

int cnt = DataGridView1.Rows.Count;
int i;
for (i = 1; i <= cnt; i++)
{
DataGridView1.Rows[i - 1].Cells["SNO"].Value = i;
}