在ASP.NET C#中重新排序多级数字
如下:
ID | Level_0 | 描述 | Level_1 Level_2 | 114 |
---|---|---|---|---|
1 | 0 | 0 0 | 0 0 | 说明1 |
115 | 1 | 1 | 0 | 描述2 |
116 | 1 1 | 1 | 1 1 | 描述3 |
117 | 1 | 2 | 等 | 描述4 |
...
从SQL选择的数据列列 如果用户删除以下这些项目,则用户界面如dataTable所关注
1.0.0 description 1
1.1.0 description 2
1.1.1 description 3
1.1.2 description 4
1.1.3 description 5
1.2.0 description 6
1.2.1 description 7
1.2.2 description 8
1.2.3 description 9
1.2.4 description 10
1.3.0 description 11
1.3.1 description 12
2.0.0 description 13
2.1.0 description 14
2.2.0 description 15
3.0.0 description 16
3.1.0 description 17
... and so on
:1.1.2,1.2.2,2.0.0,2.1.0,2.2.0,我当前的结果将是:
1.0.0 description 1
1.1.0 description 2
1.1.1 description 3
1.1.3 description 5
1.2.0 description 6
1.2.1 description 7
1.2.3 description 9
1.2.4 description 10
1.3.0 description 11
1.3.1 description 12
3.0.0 description 16
3.1.0 description 17
预期输出:
1.0.0 description 1
1.1.0 description 2
1.1.1 description 3
1.1.2 description 5
1.2.0 description 6
1.2.1 description 7
1.2.2 description 9
1.2.3 description 10
1.3.0 description 11
1.3.1 description 12
2.0.0 description 16
2.1.0 description 17
我可以知道,如何写作ASP.NET C#或VB.NET代码背后的代码在用户删除了一些错误的项目后重新排序我的多级编号,通过将我的数据表多级数字更新为预期输出中的正确数字?
DataTable columns selected from SQL as following:
id | level_0 | level_1 | level_2 | description |
---|---|---|---|---|
114 | 1 | 0 | 0 | description 1 |
115 | 1 | 1 | 0 | description 2 |
116 | 1 | 1 | 1 | description 3 |
117 | 1 | 1 | 2 | description 4 |
and so on...
A list of multilevel number displayed in the user interface as following from datatable
1.0.0 description 1
1.1.0 description 2
1.1.1 description 3
1.1.2 description 4
1.1.3 description 5
1.2.0 description 6
1.2.1 description 7
1.2.2 description 8
1.2.3 description 9
1.2.4 description 10
1.3.0 description 11
1.3.1 description 12
2.0.0 description 13
2.1.0 description 14
2.2.0 description 15
3.0.0 description 16
3.1.0 description 17
... and so on
If the user deleting these items: 1.1.2, 1.2.2, 2.0.0, 2.1.0, 2.2.0, my current result will be:
1.0.0 description 1
1.1.0 description 2
1.1.1 description 3
1.1.3 description 5
1.2.0 description 6
1.2.1 description 7
1.2.3 description 9
1.2.4 description 10
1.3.0 description 11
1.3.1 description 12
3.0.0 description 16
3.1.0 description 17
Expected output:
1.0.0 description 1
1.1.0 description 2
1.1.1 description 3
1.1.2 description 5
1.2.0 description 6
1.2.1 description 7
1.2.2 description 9
1.2.3 description 10
1.3.0 description 11
1.3.1 description 12
2.0.0 description 16
2.1.0 description 17
May I know, how to write the code behind ASP.NET C# or VB.NET code to reordering my multi-level numbering after user deleted some wrong items, by updating my data table multilevel number to the correct one in the expected output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您不介意与代码中的3个级别有关,则只需要设置3级计数器,然后在原始级别更改为每一个项目时重置每个级别:
Assuming you don't mind being tied to having 3 levels in your code, you just need to setup a 3 level counter and then reset each level when the original level changes to renumber every item: