Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Page 1:(the following is the Code incorporated in button click. When i click on button of page 1 should display the table data in page 2)
C#
protected void btnSubmit_Click(object sender, EventArgs e)
{
    string s="select * from items";
    SqlDataAdapter da = new SqlDataAdapter(s,con);
    DataTable dt = new DataTable();
    da.Fill(dt);
    Session["a"]=dt;
    Response.Redirect("Default2.aspx");
}

page 2 :(Code for displaying the table data in page 2)
C#
protected void Page_Load(object sender, EventArgs e)
{
   DataTable dt=(DataTable)Session["a"];
   GridView1.DataSource = dt;
   GridView1.DataBind();
}

Now may i know how to sort the data displayed in gridview at run time?


[Edit member="Tadit"]
Added pre tags.
[/Edit]
Posted
v2

1 solution

Something like this...
C#
dt.DefaultView.Sort = "YourColumnName ASC"; // DESC for descending.
 
Share this answer
 
Comments
JanardhanSharma 5-May-15 13:00pm    
Thank you
MOst welcome. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900