Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Clear and fill a dataset not pointing to 1st row
Message
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00736627
Message ID:
00736694
Views:
17
Hi Roland,

You want to make sure you are using the DataBinding methods of the DataGrid. After you retrieve the contents of the DataSet (and you have records retrieved), you should call the SetDataBinding method of the DataGrid like below:
// Sets the Binding position
this.BindingContext[this.MyDataSet, "MyDataTable"].Position = 0;

if (MyDataSet.Tables["MyDataTable"].Rows.Count > 0)
{
    this.grdOrders.SetDataBinding(MyDataSet, MyDataTable);
}
else
{
    this.grdOrders.DataBindings.Clear();
}
If you have Kevin McNeish's .NET book, in chapter 9 he discusses binding techniques and the sample application uses the above databinding.


>Hi,
>
>I have an windows forms app in VB.net using SqlConn/SqlDa/Datasets generated by the wizards.
>
>The first thing that I do is have the user enter in a search field and then clear and fill the dataset using parameters. The grid shows the desired rows. OK so far, but the second search (clear / fill) produces a dataset with the row pointer pointing at a different row then the first row of the grid.
>
>How do I position the row pointer to point to the first row of the newly genrated grid / dataset instead of randomly pointing to other than the first row?
>
>Thanks
>Roland
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform