0
votes

We have a strongly typed DataSet created by using the DataSet designer in Visual Studio.

Can you show us the needed coding to create a DataView from this DataSet?

This will be used in an ASP.Net VB.Net GridViewSummary.Sorting handler in a code-behind file.

Here is the coding we are trying but need help with it:

Protected Sub GridViewSummary_Sorting(sender As Object, e As GridViewSortEventArgs) Handles GridViewSummary.Sorting

    ViewState("sortExpr") = e.SortExpression
    GridViewSummary.DataSource = bindgrid()
    GridViewSummary.DataBind()
End Sub

Private Function bindgrid() As DataView

    Dim dv As DataView = New DataView
    Dim dt As DataTable = New DataTable

    dt.TableName = "Classes"
    dv.Table = dt

    If ViewState("sortExpr") IsNot Nothing Then
        dv.Sort = DirectCast(ViewState("sortExpr"), String)
    End If

    Return dv

End Function
1

1 Answers

0
votes

Dataview can be accessed like this: myDataSet.Tables[0].DefaultView .
If you want to sort GridView directly, you can convert GridView to dataview and apply sort.

(dataGridViewFields.DataSource as DataTable).DefaultView.Sort = ....    

I've answered a similar question here: can not bind to datatable with no name error while filtering a gridview