1,105,644 Community Members

Code needed to Solve Problem in DataGrid

Member Avatar
mani-hellboy
Junior Poster in Training
69 posts since Feb 2012
Reputation Points: -10 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
-1
 

Hi friends.,

Actually I use datagrid to show my result from XML file.I load my data from XML file easily.But i need Sorting method for that and i don`t know how to solve it Please give me solution for that

My code is

Imports System.Data
Imports System.Xml
Imports System.IO.StringReader
Partial Class _Default
    Inherits System.Web.UI.Page
    Dim ds As DataSet = New DataSet
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IsPostBack = False Then

            Dim dataset As DataSet = New DataSet()
            dataset.ReadXml(Server.MapPath("~\book.xml"))
            bookgrid.DataSource = dataset
            bookgrid.DataBind()

        End If
    End Sub

   
    Protected Sub bookgrid_SelectedIndexChanged(sender As Object, e As DataGridPageChangedEventArgs) Handles bookgrid.SelectedIndexChanged

        Dim dataset As DataSet = New DataSet()
        dataset.ReadXml(Server.MapPath("~\book.xml"))
        bookgrid.DataSource = dataset

        bookgrid.CurrentPageIndex = e.NewPageIndex

        bookgrid.DataBind()

    End Sub
    Protected Sub gridView_Sorting(sender As Object, e As DataGridSortCommandEventArgs) Handles bookgrid.SortCommand
        
       //I need Code here
       
    End Sub
   
End Class
Member Avatar
kamilacbe
Junior Poster
104 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 11 [?]
Skill Endorsements: 0 [?]
 
0
 

hi..

guess this would help you...

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
    {
        GridView1.Sort(this.GridView1.Columns["column name"], SortDirection.Ascending);
    }
Member Avatar
mani-hellboy
Junior Poster in Training
69 posts since Feb 2012
Reputation Points: -10 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi dude just i used datagrid not gridview

hi..

guess this would help you...

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
    {
        GridView1.Sort(this.GridView1.Columns["column name"], SortDirection.Ascending);
    }
Member Avatar
kamilacbe
Junior Poster
104 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 11 [?]
Skill Endorsements: 0 [?]
 
0
 

hii..

Sorry for the misconception... if you use datagird, i guess you can use a dataview and sort it down..

Member Avatar
mani-hellboy
Junior Poster in Training
69 posts since Feb 2012
Reputation Points: -10 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

Dataview don`t have paging

hii..

Sorry for the misconception... if you use datagird, i guess you can use a dataview and sort it down..

Member Avatar
kamilacbe
Junior Poster
104 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 11 [?]
Skill Endorsements: 0 [?]
 
0
 
Member Avatar
mani-hellboy
Junior Poster in Training
69 posts since Feb 2012
Reputation Points: -10 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 
Question Answered as of 2 Years Ago by kamilacbe
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: