P
Prasanna Ekanayake
Hi,
How can I get the DataRow that the user selected/clicked in an AllowSort
enabled DataGrid? Given below is what I'm currently trying to do to achieve
it.
I have a DataTable that is the DataSource to my DataGrid. The DataTable
contains all data from my SalesRep table which contains the following
columns.
UID - Identity Column
ID - UserID [Eg: BD00001]
FirstName
MiddleInitials
LastName
Address
Phone
Fax
Email
In the DataGrid all columns are displayed EXCLUDING the UID column. I have
enable AllowSort. Before sorting the DataGrid (by clicking the Column
header), I can get the UID of the selected/clicked row.
MessageBox.Show( ( (DataTable) cdg
cdgSalesRep.DataSource).Rows[cdgSalesRep.CurrentRowIndex][0].ToString() );
But soon as the DataGrid is sorted (by clicking the Column header), the
values return by the above statement is wrong.
If someone could point out what I'm doing wrong it would be a great help.
What I really want to do is to retrieve the DataRow that the user
selected/clicked.
Thanks in Advance!
Prasanna.
How can I get the DataRow that the user selected/clicked in an AllowSort
enabled DataGrid? Given below is what I'm currently trying to do to achieve
it.
I have a DataTable that is the DataSource to my DataGrid. The DataTable
contains all data from my SalesRep table which contains the following
columns.
UID - Identity Column
ID - UserID [Eg: BD00001]
FirstName
MiddleInitials
LastName
Address
Phone
Fax
In the DataGrid all columns are displayed EXCLUDING the UID column. I have
enable AllowSort. Before sorting the DataGrid (by clicking the Column
header), I can get the UID of the selected/clicked row.
MessageBox.Show( ( (DataTable) cdg
cdgSalesRep.DataSource).Rows[cdgSalesRep.CurrentRowIndex][0].ToString() );
But soon as the DataGrid is sorted (by clicking the Column header), the
values return by the above statement is wrong.
If someone could point out what I'm doing wrong it would be a great help.
What I really want to do is to retrieve the DataRow that the user
selected/clicked.
Thanks in Advance!
Prasanna.