添加索引列添加或删除行时自动更新 [英] Adding Index Column Auto Updated when adding or deleting Row

查看:94
本文介绍了添加索引列添加或删除行时自动更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个数据网格,我想向其添加索引列,所以我向与其连接的数据表中添加了一个列,并为此列设置了一些属性,例如

hi guys ,
i have a data grid and i Want To add Index Column to it , so i added a column to the data table attached to it and I Set Some Properties to this column like

DataColumn DC = new DataColumn("Index", typeof(int));
            this.DT_DataSource_AllOrderItems.Columns.Add(DC);
            this.DT_DataSource_AllOrderItems.Columns["Index"].AutoIncrement = true;
            this.DT_DataSource_AllOrderItems.Columns["Index"].AutoIncrementStep = 1;
            this.DT_DataSource_AllOrderItems.Columns["Index"].AutoIncrementSeed = 1;           



并且当用户删除Row时索引未更新,并且我希望在添加和删除任何一个索引时都对其进行更新

谢谢



and when user delete Row the index does not updated , and i want it to be updated when both adding and deleting any one has any advice to do that

thanks

推荐答案

不幸的是,索引不是如何工作的-因此使用触发器可能会有更多的运气-添加/删除的触发器可以更新另一个专用于此目的的表中的自动增量.

但是,如果您还需要通过删除来维护索引的某些特定顺序,则可能是自动递增索引是该任务的错误对象-您可能需要专用列来处理这种逻辑. >
您是否有逻辑上的问题示例?
Not how indexes work unfortunately - so may have more luck using triggers - a trigger on add/delete that updates an auto increment in another table dedicated for this purpose.

However, if you need some specific ordering of indexes to be maintained with deletes as well, it may be that an auto-incrementing index is the wrong object for the task - you may need a dedicated column for this kind of logic.

Have you got a logical example of the problem?


这篇关于添加索引列添加或删除行时自动更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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