在VS2005里面,datagridview里如何对某一列排序?

来源:百度知道 编辑:UC知道 时间:2024/05/17 22:19:41
在VS2005里面,datagridview里如何对某一列排序?
最好是用属性排序,因为我用这个控件的时候设的是FullRowSelect,不能点列头的~
解决问题了继续追分~
没有ALLOWSORTING这个属性啊?在哪里的啊?

首先将AllowSorting设置为true
并在绑定列中指定排序表达式,然后通过OnSortCommand方法建议SortCommand事件处理。
protected void gv_Sorting(object sender, ridViewSortEventArgs e)
{
this.SortBy = e.SortExpression;
if (this.ascOrDesc=="ASC")
{
this.ascOrDesc = "DESC";
}
else
{
this.ascOrDesc = "ASC";
}
BArticle barticle = new BArticle();
this.gv.DataSource = barticle.ListByArticleTypeID(0, "", 0, this.SortBy, this.ascOrDesc);
this.gv.DataBind();
}
如果是vs2005的话,直接将AllowSorting设置为true 就可以了。系统自己排序