Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataViews
Message
De
23/04/2003 16:56:34
 
 
À
23/04/2003 16:47:43
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Titre:
Divers
Thread ID:
00780731
Message ID:
00780874
Vues:
7
Roman,

Thanks for the reply, but I can't use it in this situation. Keys are not yet available for new data rows (they get added on the back end after updating).

But, I decided to do something like this instead:
DataRowView drv = dv[whichever one selected];

for (int i=0; i < ds.MyTable.Rows.Count; i++)
{
  if (drv.Row.Equals(ds.MyTable.Rows[i])
    break;
}
This should work ok, I think.

~~Bonnie

>You can use the DataView.Find method but you'll need a key to identify each row, hopefully you have a primary key in the table:
>
>
>    Dim objAdapter As SqlDataAdapter = _
>        New SqlDataAdapter("Select * from Orders", _
>        "Server=.;Database=northwind;Integrated Security=SSPI")
>    Dim dt As DataTable = New DataTable("Orders")
>    Dim i As Integer
>    Dim intRowIndex As Integer
>
>    objAdapter.Fill(dt)
>    dt.DefaultView.Sort = "OrderID"
>
>    Dim dv As DataView = New DataView(dt)
>    dv.RowFilter = "CustomerID = 'BOLID'"
>
>    For i = 0 To dv.Count - 1
>        intRowIndex = dt.DefaultView.Find(dv(i)("OrderID"))
>        MsgBox(intRowIndex.ToString())
>    Next
>
>
>Roman
>
>>Hi gang,
>>
>>I haven't used DataViews much at all and I'm wondering if I can do this ... I want to be able to know, for a given row in a DataView, which is the corresponding row in the DataSet:
>>
>>DataView dv = new DataView(ds.MyTable);
>>dv.RowFilter = "the filter condition";
>>
>>for (int i=0; i < dv.Count; i++)
>>{
>>  int j = dv[i].(property or method or something???)
>>  // so that I can then reference the DataSet like this:
>>  // ds.MyTable.Rows[j];
>>}
>>
>>
>>What I'm actually trying to do it to set the BindingContext Position for the DataSet, based on the row in the DataView that is being selected in a ListView.
>>
>>Any ideas?
>>
>>~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform