Can't get datagrid sort object to work

M

mister-Ed

I have an admin style datagrid wherre I'm trying to invoke Sort
feature on all the columns, but when using the following components (a
page level strSQL so the bindMyGrid sub can read it, the sub to Sort
the columns, and the datagrid attributes), i do not get the link on
the column names on the datagrid:

'the pagelevel strSQL call
Protected strSQL As String = "SELECT cardid,cat,bname,size,bfile,url
FROM cardbanners"

'binding the datagrid with all the pertinent objects
Sub bindMyGrid()

Dim objConnection As New SQLConnection(strConnection)
Dim objAdapter As New SQLDataAdapter(strSQL,
objConnection)
Dim objDataSet As New DataSet()

objAdapter.Fill(objDataSet, "cardbanners")

Dim objDataView As New
DataView(objDataSet.Tables("cardbanners"))

MyGrid.DataSource = objDataView
MyGrid.DataBind()
End Sub

'sort command call , with a label object tied to the strSQL
Sub SortCommand_OnClick(Source As Object, E As
DataGridSortCommandEventArgs)
SQLStatement.Text = strSQL & " ORDER BY " & E.SortExpression
bindMyGrid()
End Sub

'datagrid stuff on the body of the form
<div style="OVERFLOW: auto; WIDTH: 800px; HEIGHT: 600px"
runat="server">
<asp:Label id="SQLStatement" runat="server" Visible="False" />
<asp:datagrid id="MyGrid" runat="server"
Font-Name="Tahoma" CellPadding="1" Cellspacing="1" border="0"
BackColor="#BC9DD2"
Font-Size="8pt"
OnItemDataBound="MyGrid_ItemDataBound"
OnEditCommand="MyGrid_Edit"
OnDeleteCommand="MyGrid_Delete"
OnUpdateCommand="MyGrid_Update"
OnCancelCommand="MyGrid_Cancel"
AutoGenerateColumns="False"
ShowFooter="True"
OnItemCommand="MyGrid_Insert" width="100%"
AllowSorting="True"
OnSortCommand="SortCommand_OnClick">

TIA
Ed
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top