javagair
asked on
assigning dataset to gridview in vb.net
For i = 0 To Dstworkcounter2.Tables(0). Rows.Count - 1
For j = 1 To 9
DataGridView1.Item(j - 1, i).Value = Dstworkcounter2.Tables(0). Rows(i).It em(j).ToSt ring
Next
Next
have a valid dataset, don't want the first value from it
get a run time error that says the index is either negative or out of range.
i is zero and j is one at that point.
I just want to fill the datagridview with data. I remember something about turning off something in the datagridview properties.
anyone got a idea why I just can't do a simple assign to a datagridview like this?
gary
For j = 1 To 9
DataGridView1.Item(j - 1, i).Value = Dstworkcounter2.Tables(0).
Next
Next
have a valid dataset, don't want the first value from it
get a run time error that says the index is either negative or out of range.
i is zero and j is one at that point.
I just want to fill the datagridview with data. I remember something about turning off something in the datagridview properties.
anyone got a idea why I just can't do a simple assign to a datagridview like this?
gary
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I added one simple line after reading ark comments.
i = 0
For Each row As DataRow In Dst3.Tables(0).Rows
DataGridView1.Rows.Add(1) 'THIS SOLVED PROBLEM
For j = 1 To 9
DataGridView1.Item(j - 1, i).Value = Dst3.Tables(0).Rows(i).Ite m(j).ToStr ing
Next
i = i + 1
Next row
i = 0
For Each row As DataRow In Dst3.Tables(0).Rows
DataGridView1.Rows.Add(1) 'THIS SOLVED PROBLEM
For j = 1 To 9
DataGridView1.Item(j - 1, i).Value = Dst3.Tables(0).Rows(i).Ite
Next
i = i + 1
Next row
You should be able to do this and the second line of code will remove the column from being displayed.
Open in new window