views:

309

answers:

2

Hi All,

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#)

A: 

take a look at this article: Autonumbering ASP.NET grid controls.

Joshua
thank you. I got the solution
if the answer helped you, how about an upvote. If not, it would be great if you shared your solution? :)
Joshua
A: 

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; }

hrabizadeh