Results 1 to 2 of 2

Thread: [2.0] datarow

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2006
    Posts
    719

    [2.0] datarow

    how to get the current datarow of a dataset? using this code doesnt work;

    Code:
    DataRow MyRow = dDataSet.Tables["Table1"].Rows(BindingContext(dDataSet,"Table1").Position);

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] datarow

    There is no "current row" unless the table is bound to a control, in which case you should use a BindingSource. You bind the table to the BindingSource and the BindingSource to the control(s). The Current property of a the BindingSource will then return a DataRowView for the selected row. You can usually use that DataRowView directly, but if you need that actual DataRow then you can get it from the Row property:
    Code:
    DataRowView view = myBindingSource.Current as DataRowView
    DataRow row = view.Row
    The "as DataRowView" is used to cast the property value because its type is Object. That's because a BindingSource can be bound to all sorts of different lists, not just DataTables.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width