how to retrieve a full row from datagridview
hello im trying to retrieve data from an entire row in datagridview.i know how to get data from a particular cell but i want to get the particular row into an arraylist.all i can think of is this
Code:
foreach (DataRow row in dt1.Rows)
{
foreach (var item in row.ItemArray)
{
list.Add(row[item].ToString());
}
}
but it is showing the error:"The best overloaded method match for 'System.Data.DataRow.this[int]' has some invalid arguments"
please help
Re: how to retrieve a full row from datagridview
You're probably getting error because you're entering a value of var type rather than int type. The value within the square brackets is supposed to be an index. It is a way of telling the program which cell (1,2,3, etc.) from that row, it should read. I know this helps little, but this is why you're getting the error.