Sorting Datagrid with a Select Column - Does not work!

S

Sinan

Hi

I am using a datagrid with a Select Column and the SelectedIndexChanged event captures the values of the cells in the selected row.

It works fine before sorting any column. The problem starts when I sort a column and then select a row, it gives me the data of another row! Not the row I have selected

Any idea what is going wrong? Your help is highly appreciated

Here is the sort procedure I am using

"Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles DataGrid1.SortComman

strSql = "select * from dvSTD1 order by " &
e.SortExpression.ToString(

Dim objConn As New SqlConnection(strConnTxt
objConn.Open(

Dim objCmd As New SqlCommand(strSql, objConn

DataGrid1.DataSource = objCmd.ExecuteReader(
DataGrid1.DataBind(

objConn.Close(
End Sub"
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top