|
-
January 22nd, 2012, 05:23 AM
#1
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
Last edited by lamiajoyee; January 22nd, 2012 at 08:02 AM.
-
January 23rd, 2012, 11:49 AM
#2
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.
Last edited by Dragster93; January 23rd, 2012 at 05:23 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|