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

E

Eugene

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top