对Web Datagrid进行排序 [英] Sort web Datagrid

查看:63
本文介绍了对Web Datagrid进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对web数据网格asp.net进行排序。

在我使用的排序命令中:

private void MyGrid_SortCommand(对象源,< br $>
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)

{

DataView SortView = anteSet11.Ante.DefaultView;

SortView.Sort = e.SortExpression;

MyGrid.DataSource = SortView;

MyGrid.DataBind();

}


在page_load中我使用:


private void Page_Load(object sender,System.EventArgs e)

{

sqlDataAdapter1.Fill(anteSet11);

if(!IsPostBack)

{

MyGrid.DataSource = anteSet11。 Ante.DefaultView;

}

MyGrid.DataBind();

}


当我按下标题,电脑发出咔嗒声(声音为

),但是列没有排序。

我已经允许在网格的属性页面上进行排序。 />
生成列自动关闭。每列的排序命令

是合适的。

datagrid可用于其他任务,例如分页,更新,

编辑和删除。 br />
欢迎任何建议。

谢谢,

Jim

解决方案

您好


请查看以下文章
http://www.aspng.com/freebook/learn/gridevents.aspx

HTH

Ravikanth [MVP]

-----原始消息-----
我正在尝试对web数据网格asp.net进行排序。
在我使用的sort命令:

private void MyGrid_SortCommand(对象源,
System.Web.UI.WebControls.DataGridSortCommandEven tArgs e)
{DataView SortView = anteSet11。 Ante.DefaultView;
SortView.Sort = e.SortExpression;
MyGrid.DataSource = SortView;
MyGrid.DataBind();
}

在page_load中我使用:

private void Page_Load(object sender,System.EventArgs e)
{sqlDataAdapter1.Fill(anteSet11);
if(!IsPostBack) )
{
MyGrid.DataSource = anteSet11.Ante.DefaultView;
}
MyGrid.DataBind();
}

当我按下标题,计算机点击(发出声音),但列没有排序。
我允许​​在网格的属性页面上排序。
生成列 - 自动生成关闭。每列的排序命令
是合适的。
数据网格在其他任务中工作,如分页,
更新,编辑和删除。
任何建议都会受到欢迎。
谢谢,
Jim



您是否注意到我的代码是在C#中,示例位于

在vb.net中。感谢C#中的任何建议。

谢谢,

Jim

-----原帖---- -
你好

检查以下文章
http://www.aspng.com/freebook/learn/gridevents.aspx

HTH
Ravikanth [MVP]

-----原始消息-----
我正在尝试对web数据网格asp.net进行排序。
在我使用的排序命令中:

private void MyGrid_SortCommand(对象源,
System.Web.UI.WebControls.DataGridSortCommandEve ntArgs
e){
DataView SortView = anteSet11.Ante.DefaultView;
SortView.Sort = e.SortExpression;
MyGrid.DataSource = SortView;
MyGrid.DataBind();


在page_load中我使用:

private void Page_Load(object sender,System.EventArgs
e){
sqlDataAdapter1.Fill(anteSet11);
if(!IsPostBack)
{
MyGrid.DataSource = anteSet11.Ante.DefaultView;
}
MyGrid.DataBind();
}
当我按下标题时,电脑点击(发出声音)但是列没有排序。
我允许​​在网格的属性页面上进行排序。
生成列 - 自动关闭。每列的排序
命令是合适的。
数据网格适用于其他任务,如分页,


更新,

编辑和删除。 />任何建议都会受到欢迎。
谢谢,
吉姆




< blockquote>嗨Jim,


根据我的研究和经验,以下文章对你来说很有用。请仔细参考。


ASP .NET DataGrids中的有效排序
http://msdn.microsoft.com/msdnnews/2...ng/Sorting.asp


向DataGrid控件添加排序
http: //authors.aspalliance.com/aspxt...ingsortingtoda

tagrid.aspx


我希望它有所帮助。
<最好的问候,


Jacob Yang

Microsoft在线合作伙伴支持

安全! - www.microsoft.com/security

发布是按原样提供的。没有保证,也没有赋予任何权利。


I am trying to sort a web datagrid asp.net.
In the sort command I use:

private void MyGrid_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
{
DataView SortView = anteSet11.Ante.DefaultView;
SortView.Sort = e.SortExpression;
MyGrid.DataSource = SortView;
MyGrid.DataBind();
}

In the page_load I use:

private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(anteSet11);
if (!IsPostBack)
{
MyGrid.DataSource = anteSet11.Ante.DefaultView;
}
MyGrid.DataBind();
}

When I press the header, the computer clicks (makes a
sound) but the column does not sort.
I have allowed sorting on the grid''s property page.
Generate-columns-automatically is off. The sort command
for each column is appropriate.
The datagrid works in other tasks such as paging, update,
edit and delete.
Any suggestions would be welcomed.
Thanks,
Jim

解决方案

Hi

Check the following article
http://www.aspng.com/freebook/learn/gridevents.aspx

HTH
Ravikanth[MVP]

-----Original Message-----
I am trying to sort a web datagrid asp.net.
In the sort command I use:

private void MyGrid_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEven tArgs e)
{
DataView SortView = anteSet11.Ante.DefaultView;
SortView.Sort = e.SortExpression;
MyGrid.DataSource = SortView;
MyGrid.DataBind();
}

In the page_load I use:

private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(anteSet11);
if (!IsPostBack)
{
MyGrid.DataSource = anteSet11.Ante.DefaultView;
}
MyGrid.DataBind();
}

When I press the header, the computer clicks (makes a
sound) but the column does not sort.
I have allowed sorting on the grid''s property page.
Generate-columns-automatically is off. The sort command
for each column is appropriate.
The datagrid works in other tasks such as paging, update,edit and delete.
Any suggestions would be welcomed.
Thanks,
Jim
.



Did you notice that my code was in C#, the example sited
is in vb.net. Any suggestions in C# would be appreciated.
Thanks,
Jim

-----Original Message-----
Hi

Check the following article
http://www.aspng.com/freebook/learn/gridevents.aspx

HTH
Ravikanth[MVP]

-----Original Message-----
I am trying to sort a web datagrid asp.net.
In the sort command I use:

private void MyGrid_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEve ntArgs e){
DataView SortView = anteSet11.Ante.DefaultView;
SortView.Sort = e.SortExpression;
MyGrid.DataSource = SortView;
MyGrid.DataBind();
}

In the page_load I use:

private void Page_Load(object sender, System.EventArgs e){
sqlDataAdapter1.Fill(anteSet11);
if (!IsPostBack)
{
MyGrid.DataSource = anteSet11.Ante.DefaultView;
}
MyGrid.DataBind();
}

When I press the header, the computer clicks (makes a
sound) but the column does not sort.
I have allowed sorting on the grid''s property page.
Generate-columns-automatically is off. The sort commandfor each column is appropriate.
The datagrid works in other tasks such as paging,


update,

edit and delete.
Any suggestions would be welcomed.
Thanks,
Jim
.


.



Hi Jim,

Based on my research and experience, the following articles are useful to
you. Please refer to them carefully.

Effective Sorting in ASP .NET DataGrids
http://msdn.microsoft.com/msdnnews/2...ng/Sorting.asp

Adding Sorting to a DataGrid Control
http://authors.aspalliance.com/aspxt...ingsortingtoda
tagrid.aspx

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


这篇关于对Web Datagrid进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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