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:
00737535
Views:
27
Roland,

Try adding the following after you Clear the DataSet (towards the top of your sample code):
Me.dgPersonnel.DataBindings.Clear()
Before you set databindings, you should clear them.

>Hi Cathi,
>
>I tried the following and it did not work.
>
> 'Attempt to load the dataset with Source Data.
> Me.Personnel01_Ds1.Clear()
> 'Intialize Dataset for Personnel - Default values
> Me.SqlDataAdapter1.FillSchema(Personnel01_Ds1, SchemaType.Source, "Personnel")
> Me.SqlDataAdapter1.Fill(Personnel01_Ds1, "Personnel")
> If Personnel01_Ds1.Tables("Personnel").Rows.Count > 0 Then
> Me.dgPersonnel.SetDataBinding(Personnel01_Ds1, "Personnel")
> Me.BindingContext(Me.Personnel01_Ds1, "Personnel").Position = 0
> Else
> Me.dgPersonnel.DataBindings.Clear()
> End If
> Me.SqlDataAdapter2.Fill(Personnel01_Ds1, "JobType")
>
>Any other suggestions?
>
>Thanks you Cathi and Bonnie.
>Roland
>
>====================================================================
>>Bonnie,
>>
>>Thanks for pointing this out. My mistake in the code I posted.
>>
>>>Roland,
>>>
>>>I haven't used a grid, but I've data bound enough controls ... try setting the BindingContext Postion after you've set the DataBinding.
>>>
>>>~~Bonnie
>>>
>>>
>>>>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
>>>>
-----------------------------------------

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