本文介绍了在Gridview上保持排序顺序而另一个排序。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在1张桌子上进行分类时,另一张桌子会回到原来的

顺序。


我可以设置什么呢,它保持其他当前gridview的订单的顺序。


我在cs文件中的''onpageload''中设置了所有gridview值。

When I do a sorta on 1 table, then the other table goes back to the original
order.

What can I set so, it keeps the order of the other current gridview''s order.

I set all the gridview values in my ''onpageload'' in the cs file.

推荐答案



您是否尝试过从同一数据表创建不同的视图:


DataView view1 = new DataView(YourDataTable);

view1.Sort =" ColumnNameToBeSorted ASC" ;;

Grid1.DataSource = view1;

Grid1.DataBind();


DataView view2 = new DataView(YourDataTable);

view2.Sort =" SomeOtherColumnNameToBeSorted ASC";

Grid2.DataSource = view2;

Grid2.DataBind();

Have you tried create different views from the same data table:

DataView view1 = new DataView(YourDataTable);
view1.Sort = "ColumnNameToBeSorted ASC";
Grid1.DataSource = view1;
Grid1.DataBind();

DataView view2 = new DataView(YourDataTable);
view2.Sort = "SomeOtherColumnNameToBeSorted ASC";
Grid2.DataSource = view2;
Grid2.DataBind();




原始

original



订单的顺序。

order.



您是否尝试过从同一数据表创建不同的视图:


DataView view1 = new DataView(YourDataTable);

view1.Sort =" ColumnNameToBeSorted ASC" ;;

Grid1.DataSource = view1;

Grid1.DataBind();


DataView view2 = new DataView(YourDataTable);

view2.Sort =" SomeOtherColumnNameToBeSorted ASC";

Grid2.DataSource = view2;

Grid2.DataBind();


Have you tried create different views from the same data table:

DataView view1 = new DataView(YourDataTable);
view1.Sort = "ColumnNameToBeSorted ASC";
Grid1.DataSource = view1;
Grid1.DataBind();

DataView view2 = new DataView(YourDataTable);
view2.Sort = "SomeOtherColumnNameToBeSorted ASC";
Grid2.DataSource = view2;
Grid2.DataBind();



我不确定这是否有帮助。我猜这与

在页面加载时调用它以及帖子后台如何工作有关。

排序总是回发,所以有没有办法保持当前

gridview设置?

I''m not sure if that would help. I''m guessing it has something to do with
calling it on page load and how the post backs work.
Sorting always does a postback, so is there a way to keep the current
gridview settings?




两种方式:


1)在ViewState中存储排序顺序


2)使用Ajax


另外,确保你不想在回发上运行的任何代码是

被if(!IsPostback)包围{...}

Two ways:

1) Store the sort order in ViewState

2) Use Ajax

Also, make sure that any code you don''t want to run on postback is
surrounded by if (!IsPostback) {...}


这篇关于在Gridview上保持排序顺序而另一个排序。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 18:37