DataGrid. How to keep the right keyfield value when Sort the DataGrid?

Discussion in 'ASP .Net' started by Eugene, Sep 28, 2004.

  1. Eugene

    Eugene Guest

    Hi everybody!

    Got the logical error (wrong row (SSN) selected on
    SelectedIndexChange event) when made a sort by non-key field in
    Datagrid.

    Used this Sub to keep the keyfield ("SSN"):

    Private Sub dgrMain_SelectedIndexChanged(ByVal sender As
    System.Object,ByVal e As System.EventArgs) Handles
    dgrMain.SelectedIndexChanged
    Session("SSN") =
    dgrMain.Items(dgrMain.SelectedIndex).Cells(1).Text
    Response.Redirect("Default.aspx")
    End Sub

    Did sorting in a standart way. Everything works fine when the Grid is
    sorted by SSN (what is cells(1)). But when you sort by any other field
    it still choose the row like sorted by SSN.
    Thanks for the help.
    Eugene
     
    Eugene, Sep 28, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GoodMorningSky

    How to sort datagrid and keep the bound data as sorted?

    GoodMorningSky, Sep 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    157
    GoodMorningSky
    Sep 9, 2004
  2. mharness

    read keyfield value from selected row in datagrid

    mharness, Oct 11, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    112
    mharness
    Oct 11, 2004
  3. Richard McClelland

    DataGrid does not keep sort when I move to another page

    Richard McClelland, Nov 3, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    154
    Richard McClelland
    Nov 4, 2004
  4. Navin
    Replies:
    1
    Views:
    702
    Ken Schaefer
    Sep 9, 2003
  5. mharness
    Replies:
    2
    Views:
    171
    Bob Barrows [MVP]
    Oct 11, 2004
Loading...

Share This Page