Get the correct DataTable Row?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • R Agam

    #1

    Get the correct DataTable Row?

    Hi

    I am using a DataGrid with sorting enabled.
    When the user double click on a Row I get the selected index. Now How can I
    get the DataTable row corresponding to the selected index?



    Thanks,
    Ronen


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Get the correct DataTable Row?

    Ronen,

    If you have the row number, you can pass the row number to the DataView
    returned by the DefaultView property on the DataTable. This view is what is
    being sorted. The indexer for the view will return the items in the correct
    order.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "R Agam" <ragam@mmm.co m> wrote in message
    news:%23PIactRV DHA.532@TK2MSFT NGP09.phx.gbl.. .[color=blue]
    > Hi
    >
    > I am using a DataGrid with sorting enabled.
    > When the user double click on a Row I get the selected index. Now How can[/color]
    I[color=blue]
    > get the DataTable row corresponding to the selected index?
    >
    >
    >
    > Thanks,
    > Ronen
    >
    >[/color]


    Comment

    • MB

      #3
      Re: Get the correct DataTable Row?

      Hi R Agam

      the only way i found is using BindingManagerB ase

      exp:
      BindingManagerB ase bm = MyGrid.BindingC ontext[MyGrid.DataSour ce,
      MyGrid.DataMemb er];

      string Name = ((DataRowView)b m.Current).Row["Name"].ToString();

      Using DefaultView it dosn't work for me (with sorting enabled)

      string Name =
      Dt.DefaultView. Table.Rows[MyGrid.CurrentR owIndex]["Name"].ToString());



      "R Agam" <ragam@mmm.co m> wrote in message
      news:#PIactRVDH A.532@TK2MSFTNG P09.phx.gbl...[color=blue]
      > Hi
      >
      > I am using a DataGrid with sorting enabled.
      > When the user double click on a Row I get the selected index. Now How can[/color]
      I[color=blue]
      > get the DataTable row corresponding to the selected index?
      >
      >
      >
      > Thanks,
      > Ronen
      >
      >[/color]


      Comment

      Working...