在我的DatagridView中,在排序任何列时禁用(id / Sl.no)列的排序? [英] In my DatagridView, Disable sorting of (id/ Sl.no) column when Sorting any column?

查看:121
本文介绍了在我的DatagridView中,在排序任何列时禁用(id / Sl.no)列的排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DataColumn SlCol = new DataColumn(#,typeof(System.Int32));

dtGetList.Columns.Add(SlCol);

SlCol.AutoIncrement = true;

SlCol.AutoIncrementSeed = 1;

Ex:GridLoad上的网格

sl.No名称

1 A

2 B

3 C

4 D

5 E

6 F $ / $


排序名称栏后



DataColumn SlCol = new DataColumn("#", typeof(System.Int32));
dtGetList.Columns.Add(SlCol);
SlCol.AutoIncrement = true;
SlCol.AutoIncrementSeed = 1;
Ex: Grid On FormLoad
sl.No Name
1 A
2 B
3 C
4 D
5 E
6 F

After Sorting Name Column

sl.No  Name
6       f
5       e
4       d
3       c
2       b
1       a





我所需的o / p是





my required o/p is

sl.No  Name
1       f
2       e
3       d
4       c
5       b
6       a

推荐答案

根据我的理解,排序后的线程序列号应该是串行的。



而不是在数据表中添加序列号列更好地包含在datagrid的设计器中,使用下面的文本<![CDATA [<%] #Container.Eval(DataGrid.ItemIndex + 1)%>]]> 并根据需要执行操作。 (或)在OnDataGridItemDataBound事件中实现序列号。
As per my understand the thread after your sorting the serial number should be in serial.

Instead of adding Serial Number column in datatable better to include in designer of datagrid by using below text <![CDATA[<%#Container.Eval(DataGrid.ItemIndex+1)%>]]> and perform action as you want. (or) Implement the serial number in OnDataGridItemDataBound event.


我不确定但我们可以在gridview的数据绑定事件下添加这样的逻辑,即根据条件禁用特定列的排序。 />


Item_Bound(Object sender,DataGridItemEventArgs e)
I am not sure but we can add such logic under gridview's databound event i.e. to disabale the sorting on specific column based on condition.

Item_Bound(Object sender, DataGridItemEventArgs e)


这篇关于在我的DatagridView中,在排序任何列时禁用(id / Sl.no)列的排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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