如何对列表项进行排序并制作另一个已排序项列表? [英] How to sort list item and make another lists of sorted items?

查看:114
本文介绍了如何对列表项进行排序并制作另一个已排序项列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的列表中有以下项目,我想在多个子列表中对此列表进行排序以便进一步处理。



我的列表项目是,



表= Corporate_Name $$

表= Customer_Name $$ sanjay

表= Cutomer_Name_For_Print_At_Bottom $$ sanjay

表1 = Company_Name $$ RWL Healthworld Limited

表1 = Bill_Status $$ G

表1 = Home_Delievery $$ N

表2 = User_Name $$ Nazam

Table2 = User_Name $$ Nazam

Table2 = User_Name $$ Nazam

Table3 = payment_value $$ 305.49

表3 = cash_amount_taken $$ 1000.00

表3 = cash_amount_returned $$ 694.51

表3 = TenderName $$现金

表3 = TenderType $$ 1



我想制作子列表,例如,

列表1,其项目的开头是表格,

list 2有项目以Table1开头,

列表3,其中包含以Table2开头的项目,

等等;然而,桌子的数量是



我尝试过:



添加代码



I have following items in my list and i want to sort this list in multiple sub lists for further process.

my list items are,

Table=Corporate_Name$$
Table=Customer_Name$$sanjay
Table=Cutomer_Name_For_Print_At_Bottom$$sanjay
Table1=Company_Name$$RWL Healthworld Limited
Table1=Bill_Status$$G
Table1=Home_Delievery$$N
Table2=User_Name$$Nazam
Table2=User_Name$$Nazam
Table2=User_Name$$Nazam
Table3=payment_value$$305.49
Table3=cash_amount_taken$$1000.00
Table3=cash_amount_returned$$694.51
Table3=TenderName$$Cash
Table3=TenderType$$1

I want to make sub lists like,
list 1 having items whose starts with Table,
list 2 having items whose starts with Table1,
list 3 having items whoes starts with Table2,
and so on; however the number of tables are

What I have tried:

Adding code

cmd = new MySqlCommand();
                                       cmd.CommandType = CommandType.StoredProcedure;
                                       cmd.CommandText = "sp_GetPosBillDetail_ForPrint";
                                       cmd.Parameters.Add(new MySqlParameter("inParam", onestr));
                                       cmd.Parameters.Add(new MySqlParameter("outParam", "@outParam"));
                                       cmd.Parameters["@outParam"].Direction = ParameterDirection.Output;
                                       cmd.Connection = con1;
                                       table = new DataTable();
                                       DataSet ds = new DataSet();
                                       adapter = new MySqlDataAdapter(cmd);
                                       adapter.Fill(ds);
                                       List<string> dtcol = new List<string>();

                                       for (int i = 0; i < ds.Tables.Count; i++)
                                       {
                                           foreach (DataColumn column in ds.Tables[i].Columns)
                                           {
                                               for (int m = 0; m < ds.Tables[i].Rows.Count; m++)
                                               {
                                                   dtcol.Add(ds.Tables[i] + "$$" + column + "$$" + ds.Tables[i].Rows[m][column].ToString());
                                               }
                                           }
                                       }





我尝试过编写开关盒但是不正常工作。



I have tried with writing switch case but not working properly.

switch (dtcol[n].Substring(0,5))
                                           {
                                               case "Table":

                                                   break;

                                               case "Table1":                                                 
                                                      break;

                                               case "Table2":
                                                   break;  



但是我不知道这些逻辑不可能的表的数量。


but i dont know number of tables thats why this logic is not possible.

推荐答案



Table = Customer_Name

Table=Customer_Name


sanjay

Table = Cutomer_Name_For_Print_At_Bottom
sanjay
Table=Cutomer_Name_For_Print_At_Bottom


sanjay

表1 = Company_Name
sanjay
Table1=Company_Name


这篇关于如何对列表项进行排序并制作另一个已排序项列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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