如何对gridview中显示的数据表数据进行排序

时间:2022-11-11 14:44:53

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)

第1页:(以下是按钮点击时包含的代码。当我点击第1页的按钮时,应显示第2页的表格数据)

 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)

第2页:(第2页中显示表格数据的代码)

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?

现在我可以知道如何在运行时对gridview中显示的数据进行排序吗?

1 个解决方案

#1


GridView allows users to sort using AllowSorting property. Take a look here.

GridView允许用户使用AllowSorting属性进行排序。看看这里。

#1


GridView allows users to sort using AllowSorting property. Take a look here.

GridView允许用户使用AllowSorting属性进行排序。看看这里。