Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all...

I am developing one website, for that i need gridview cell index or cell value.
Please help me..
Posted
Comments
Prerak Patel 25-Aug-11 2:56am    
Elaborate more.
Shahan Ayyub 25-Aug-11 3:16am    
Kindly let us know about at which point you have issues. Are you iterating over gridview rows ?

1 solution

so many ways but as per requirement ...

1) in databound event : DataGridViewCell cell = this.dataGridView[e.ColumnIndex, e.RowIndex];

you can use this in for loop

2) string strFirstName = Grid1.Rows[3].Cells["FirstName"]

3) GridViewRow gRow = GridView1.Rows[RowIndex];

e.g.
C#
for (int i = 0; i < grdMyGrid.Rows[0].Cells.Count; i++)
{
grdMyGrid.Rows[0].Cells[i].Width = Unit.Pixel(200);
}



in javascript
C#
var n = document.getElementById("GridView1").rows.length;
            var i;
            for (i = 2; i <= n; i++) {
                tb = document.getElementById("GridView1_ctl0" + i + "_TextBox1");
                tb.value = i;
            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900