DevExpress的GirdView怎样设置列头的点击事件,实现某列的自定义排序? devexpresswinform.net数据 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 GridView的EndSorting事件,点击列头查询数据、重新绑定GridControl的数据源。 使用自定义排序。https://documentation.devexpress.com/#WindowsForms/CustomDocument3071 GirdView实现某列显示20条数据自定义排序示例 <asp:GridView ID="gvKehu" runat="server" AutoGenerateColumns="False" CellPadding="4" Font-Size="9pt" ForeColor="#333333" GridLines="None" Width="500px" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDeleting="GridView1_RowDeleting" OnRowDataBound="gvKehu_RowDataBound"> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <Columns> <asp:BoundField HeaderText="客户ID" DataField="BlogID" /> <asp:BoundField HeaderText="客户姓名" DataField="UserName" /> <asp:BoundField HeaderText="客户性别" DataField="Sex" /> <asp:BoundField HeaderText="QQ" DataField="QQ" /> <asp:BoundField HeaderText="注册时间" DataField="RegTime" /> <asp:HyperLinkField DataNavigateUrlFields="BlogID" DataNavigateUrlFormatString="BlogInfo.aspx?id={0}" HeaderText="详细信息" Text="详细信息" /> <asp:CommandField HeaderText="删除" ShowDeleteButton="True" /> </Columns> <SelectedRowStyle BackColor="#C5BBAF" ForeColor="#333333" Font-Bold="True" /> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" /> <RowStyle BackColor="#E3EAEB" /> <EditRowStyle BackColor="#7C6F57" /> </asp:GridView>//加载绑定按时间降序显示前20条数据protected void Page_Load(object sender, EventArgs e) { SqlData da = new SqlData();//创建数据集对象 this.gvKehu.DataSource = da.ExceDS("select top 20 * from ST_news order by ST_n_date desc");//选择数据表按时间显示前20条数据 gvKehu.DataKeyNames = new string[] { "BlogID" };// gvKehu.DataBind();//绑定控件显示 } 如果是后台绑定的话,点击的时候重新绑定一次试试。我都是用ASPxGridView的。这里的功能更多,更方便。 DataGridView扩展类遇到的问题 C# 监控键盘 【100分】这样的功不知能不能实现 关于字符串参数替换,正因为不知这是什么问题,我才不知道用什么关键字去搜,所以来发贴了 光盘加密的问题 在listView中如何把当前选中项加入另一个listView中? 在comboBox怎才能只输入数字多谢 ASP.NET+C#+ACCESS的问题 DataGrid中使用排序功能的问题 求一循环语句,非常简单(对我来说比较难) 如何解决c#采用httprequest调用java的soap接口汉字不能识别问题 disposed子窗体的问题
https://documentation.devexpress.com/#WindowsForms/CustomDocument3071
<asp:GridView ID="gvKehu" runat="server" AutoGenerateColumns="False" CellPadding="4"
Font-Size="9pt" ForeColor="#333333" GridLines="None" Width="500px" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDeleting="GridView1_RowDeleting" OnRowDataBound="gvKehu_RowDataBound">
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField HeaderText="客户ID" DataField="BlogID" />
<asp:BoundField HeaderText="客户姓名" DataField="UserName" />
<asp:BoundField HeaderText="客户性别" DataField="Sex" />
<asp:BoundField HeaderText="QQ" DataField="QQ" />
<asp:BoundField HeaderText="注册时间" DataField="RegTime" />
<asp:HyperLinkField DataNavigateUrlFields="BlogID" DataNavigateUrlFormatString="BlogInfo.aspx?id={0}"
HeaderText="详细信息" Text="详细信息" />
<asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
</Columns>
<SelectedRowStyle BackColor="#C5BBAF" ForeColor="#333333" Font-Bold="True" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<RowStyle BackColor="#E3EAEB" />
<EditRowStyle BackColor="#7C6F57" />
</asp:GridView>
//加载绑定按时间降序显示前20条数据
protected void Page_Load(object sender, EventArgs e)
{
SqlData da = new SqlData();//创建数据集对象
this.gvKehu.DataSource = da.ExceDS("select top 20 * from ST_news order by ST_n_date desc");//选择数据表按时间显示前20条数据
gvKehu.DataKeyNames = new string[] { "BlogID" };//
gvKehu.DataBind();//绑定控件显示
}