在Gridview上保持排序顺序而另一个排序。 [英] Keeping sort order on a Gridview while another is sorted.

查看:59
本文介绍了在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.

推荐答案

2月14日下午3:06,Cindy Lee < cindy ... @ hotmail.comwrote:
On Feb 14, 3:06 pm, "Cindy Lee" <cindy...@hotmail.comwrote:

当我在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();




" Quoc Linh" < le ******** @ yahoo.com写了留言

新闻:11 ********************** @ j27g2000cwj.googlegr oups.com ...

"Quoc Linh" <le********@yahoo.comwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...

2月14日下午3:06,Cindy Lee < cindy ... @ hotmail.comwrote:
On Feb 14, 3:06 pm, "Cindy Lee" <cindy...@hotmail.comwrote:

当我在1个表上进行sorta,然后另一个表回到
When I do a sorta on 1 table, then the other table goes back to the



原始

original


order。


我可以设置什么,它保持其他当前gridview的
order.

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



订单的顺序。

order.



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

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();



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

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

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

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?


" Cindy Lee" < ci ****** @ hotmail.comwrote in message

news:Od ************** @ TK2MSFTNGP04.phx.gbl ...
"Cindy Lee" <ci******@hotmail.comwrote in message
news:Od**************@TK2MSFTNGP04.phx.gbl...

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

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

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

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上保持排序顺序而另一个排序。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆