Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate datagrid with subset of datatable

Status
Not open for further replies.
Jan 9, 2003
147
US
Hi All,

I'm trying to select subsets of data and bind them to programatically generated datagrids. The code I came up with seems like it should work, and it almost does....but not quite

When I do this:
Code:
TheDataGrid.DataSource = MyDataSet.Tables("MyTable").Select("MyItem='" & AnItem & "'")
TheDataGrid.DataBind()

I get this in my datagrid:
Code:
|----------------------|
| RowError | HasErrors |
|----------------------|
|          | False     |
|          | False     |       
|----------------------|

The number of items in the datagrid will change depending on what I "select", so that part works, but how do I get the data and not an error count of sorts?

Thanks,
FD
 
Ok, kinda figured this one out even though I'm not thrilled with the solution:

Basically I had to create a new DataSet and then call DataSet.Merge(MyDataSet.Tables("MyTable").Select("MyItem='" & AnItem & "'"))


(Actually I put the results into a DataRow array first, but I had already done this earlier so it was available, but I think the above would work as well).

Maybe this will help someone out in the future...

-FD
 
I tested your original code, and I received no errors. There must be something else that is causing your problem.
 
Hmm, that's weird. Thanks for the test jbenson. If I have time I'll have to re-visit the issue to see what was going on.

-FD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top