Hi Guys,
I am struggling with sorting the datagrid along with paging...
here is my code. Everything works fine expect the sorting thing...i am not sure how to get hold of user entered values...am i not sure if i calling the sort function correctly...
Code:
<script language="VB" runat="server">
Protected strSQL AS String
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
CodeSearchList.CurrentPageIndex = 0
BindData()
End Sub
Sub BindData()
Dim DS As DataSet
Dim SqlConn As SqlConnection
Dim Sqlda as SqlDataAdapter
Dim strConnection As String
Try
strConnection=ConfigurationSettings.AppSettings("conString")
SqlConn = New SqlConnection(strConnection)
strSQL= "Select * from SubConsultant where ((CODE LIKE '%" +Codetxtbox.text+ "%') OR Description LIKE '%" +Codetxtbox.text+ "%'))"
Sqlda = New SqlDataAdapter(strSQL, SqlConn)
DS = new DataSet()
Sqlda.Fill(DS,"LookupCodes")
If DS.Tables(0).Rows.Count > 0 Then
CodeSearchList.DataSource = DS.Tables("LookupCodes")
CodeSearchList.DataBind()
CodeSearchList.Visible = True
else
Response.Write ("No Records Found")
CodeSearchList.Visible = False
end if
Catch ex AS Exception
Response.Write(ex.ToString & "<br>")
Finally
SqlConn.Close()
End Try
End Sub
Sub CodeSearchList_Paging(sender As Object, e As DataGridPageChangedEventArgs)
CodeSearchList.CurrentPageIndex = e.NewPageIndex
BindData()
End Sub
Sub SortCommand_OnClick(Source As Object, E As DataGridSortCommandEventArgs)
strSQL = strSQL & " ORDER BY " & E.SortExpression
BindData()
End Sub
</script>
Thanks in advance...