卡通手机壳图片大全集:ASP.NET的DataGrid如何实现通用的排序和自定义列?

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/14 12:05:08

自定义列
选择datagrid的属性AutoGenerateColumns 将其设置为false
然后再框架编辑那里写<columns><asp:templatecolumns><itemtemplate>
数据绑定我用databinder
<%# DataBinder.Eval(Container.DataItem,"columnname")%>
</itemtemplate></asp:templatecolumns></columns>

sort 也是用属性AllowSorting 将其设置为true
在其sortcommand事件里写
DataView dv = new DataView(dt);

// The DataView provides an easy way to sort. Simply set the Sort property with
// the name of the field to sort by.
dv.Sort = e.SortExpression; // sortexpression