Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining the row position in a dataset
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00667651
Message ID:
00669328
Views:
24
So, a DataView is *always* a subset of a DataSet? IOW, if you are accessing a DataView in a grid and you make changes in that grid, thus making changes in that DataView ... those changes are actually being made in the DataSet?



>DataViews allow you to filter and sort data in a DataSet. They allow you to display a sub-set of the records in a DataSet or DataTable as well as filtering the DataSet records using their row state. For example, all rows thast have been changed, or all rows that have been marked for deletion.
>
>>Thanks Cathi ... as I said, I haven't used DataViews, so I know nothing about them.
>>
>>What are the pros and cons to using a DataView vs using the DataSet's tables?
>>
>>~~Bonnie
>>
>>
>>>All DataTables in DataSets have default DataViews that you can use or you can create your own. Even it you use Typed DataSets they are still based on the DataSet so all the capabilites are available.
>>>
>>>>Hi Cathi,
>>>>
>>>>Just wondering how this would be handled if you weren't using DataViews, just DataSets (we use typed DataSets). I haven't gotten to the point of messing around with this yet, but will have to soon.
>>>>
>>>>~~Bonnie
>>>>
>>>>
>>>>>In Visual Studio .NET, data sources do not maintain a notion of a control's
>>>>>position within the data contained. In contrast, other data-access
>>>>>technologies, such as ADO, typically maintain a current record and provide
>>>>>ways for you to navigate to other records. Some people may be surprised to
>>>>>see that the data no longer "knows" where the current record is itself, due
>>>>>to the absence of a cursor. Now, without cursors, you can have multiple
>>>>>positions set on the same store of data.
>>>>>
>>>>>You should use the Find method of the DataView. This
>>>>>method returns the item number for that row. Then, just assign it to the
>>>>>position property of the CurrencyManager. You can get the DataView by
>>>>>casting the List property of the CurrencyManager. The Find method searches
>>>>>the sorted column(s), so you would have to sort by the key field.
>>>>>
>>>>>In this sample, you use the DataView.Find method to retrieve the record
>>>>>position
>>>>>and update the CurrencyManager object. This synchronizes the row pointer in
>>>>>the
>>>>>DataGrid. If you want to highlight the row beyond this, you can use the
>>>>>DataGrid.Select method.
>>>>>
>>>>>The
>>>>>following Knowledge Base article demonstrates a searchable DataGrid:
>>>>>
>>>>> Q308070 HOW TO: Implement a Searchable DataGrid by Using ADO.NET
>>>>>
>>>>>Here is a portion of the article that pertains to what you doing:
>>>>>
>>>>>This sample uses the CurrencyManager object to manipulate currency. You can
>>>>>also
>>>>>use the BindingManagerBase class, which is the base class for the
>>>>>CurrencyManager. All data binding is done through DataView classes. To
>>>>>synchronize your controls and the CurrencyManager, the controls must be
>>>>>bound to
>>>>>the same DataView.
>>>>>
>>>>> 'Search for the record in the DefaultView.
>>>>> 'If found, move the pointer to the correct record in the grid.
>>>>> Dim i As Integer
>>>>> i = dv.Find(txtFind.Text) ' Locates record in DefaultView.
>>>>> ' Does not move grid pointer or CM.
>>>>> If i > dv.Table.Rows.Count Or i < 0 Then
>>>>> MsgBox("Record Not found", MsgBoxStyle.Information, "Record Not
>>>>>Found")
>>>>> Else
>>>>> 'CM.Position = i ' Synchronizes Cm and Grid Pointer.
>>>>> End If
>>>>>
>>>>>
>>>>>
>>>>>>I am looking for a way to set the CurrencyManager.Position when I know the datarow.
>>>>>>
>>>>>>My specific problem: I have an array of child datarows, each with a specific rowid within the form's dataset. I want to set currencymanager.position to a selected child record - this updates my displayed values based on the databindings I've established for the form controls.
>>>>>>
>>>>>>The datarow object contains a member named rowid. Rowid holds an integer which corresponds to the value I want to set to currencymanager.position, however, the rowid member is private and can not be accessed programatically.
>>>>>>
>>>>>>Does anyone know any workaround for this problem? Any direction would be greatly appreciated!
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform