why does this grid not sort??

D

Daniel Bass

I've got a data grid, with paging, and sorting allowed. I
can find loads of examples, and have previous done this,
when generating all the data from my database at run
time, progmatically.

Now I'm trying to do it through the design editor, using
datasets instead of dataviews, etc...

is what i'm doing below the wrong approach when
attempting this in a "design time" fashion?
why does it not work?

' ---------- CODE START

' other initialization and delcarations here...

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

If Not Page.IsPostBack Then
' Put user code here to initialize the data
source
sqldataadapterLogger.Fill(DataSetLogger)
DataGrid1.DataSource =
DataSetLogger.AvenueLog.DefaultView
DataGrid1.DataBind()
Session("dataset") = DataSetLogger
Session("pageindex") = 0
Session("sortcolumn") = Nothing
End If

End Sub

Private Sub BindData()

DataSetLogger = Session("dataset")
Dim currentPageIndex As Integer = Session
("pageindex")
Dim currentSortColumn As String = Session
("sortcolumn")
Dim dv As DataView =
DataSetLogger.AvenueLog.DefaultView

' apply sorting
If (Not currentSortColumn Is Nothing) Then
dv.Sort = currentSortColumn
End If

' apply current page
DataGrid1.CurrentPageIndex = currentPageIndex

' bind data
DataGrid1.DataSource = dv
DataGrid1.DataBind()


End Sub

Private Sub DataGrid1_PageIndexChanged(ByVal source
As Object, ByVal e _
As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) _
Handles DataGrid1.PageIndexChanged

Session("pageindex") = e.NewPageIndex
BindData()

End Sub


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

Session("sortcolumn") = e.SortExpression
BindData()

End Sub

' ------------ CODE END

Thanks for your time and help,
in anticipation.
Daniel.
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top