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:
00737196
Views:
17
Hi Cathi,

I tried the following and it did not seem to work.

Me.SqlDataAdapter1.Fill(Personnel01_Ds1, "Personnel")
Me.BindingContext(Me.Personnel01_Ds1, "Personnel").Position = 0
If Personnel01_Ds1.Tables("Personnel").Rows.Count > 0 Then
Me.dgPersonnel.SetDataBinding(Personnel01_Ds1, "Personnel")
Else
Me.dgPersonnel.DataBindings.Clear()
End If

The datagrid row position (the row > selector) still was on another position down the grid. Not on the first row.

Any suggestions?

Hope you had a good New Year!

Thanks
Roland

========================================================================


>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform