I am using a foreach loop to insert data into a gridview such as this.
foreach (GridViewRow _row in grvbillDetail.Rows)
{
_row = text;
_row = text;
_row = int;
_row = int;
}
How can i make some of the data print on the first row and some print on the second row?
Thanks in advance!
GridViewRow.RowIndex
is the key to access your rows here.
Try this.
foreach (GridViewRow _row in grvbillDetail.Rows)
{
if(_row.RowIndex == 0)
{
//this is the first row. do whatever you want here
}
if(_row.RowIndex == 1)
{
//this is the second row. do whatever you want here
}
//_row = text;
//_row = text;
//_row = int;
//_row = int;
}
By the way, if you want to access only the first and second row, do something like this
GridViewRow firstRow = grvbillDetail.Rows[0] as GridViewRow;
GridViewRow secondRow = grvbillDetail.Rows[1] as GridViewRow;