将arraylist转换为数据集 [英] convert a arraylist to dataset

查看:97
本文介绍了将arraylist转换为数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

---这里的数组列表给了我所有的记录--------------------------

< br $>


TMS.API.Schedule.VO_Schedule_SC obj_Schedule = new TMS.API.Schedule.VO_Schedule_SC();

obj_Schedule.StartDate = DateTime.Parse (txt_From_date.Text).ToString(MM / dd / yyyy HH:mm:ss);

obj_Schedule.EndDate = DateTime.Parse(txt_To_date.Text).ToString(MM / dd / yyyy HH:mm:ss);

obj_Schedule.Hub_ID = ddl_Hub.SelectedValue;

obj_Schedule.UserID = string.IsNullOrEmpty(txtEmployeeID.Text)? string.Empty:txtEmployeeID.Text;



INT_Schedule obj_Int_Schedule = new INT_Schedule();

ArrayList dsRecords = obj_Int_Schedule.GetAllImportedUser_Records(obj_Schedule,PageToDisplay ,PageSize);



-----------------------我得到10条记录--- -----每条记录有7栏---------------------



现在我想要把这个数组列表转换成数据集。



怎么做?

---here the array list gives me all the records--------------------------


TMS.API.Schedule.VO_Schedule_SC obj_Schedule = new TMS.API.Schedule.VO_Schedule_SC();
obj_Schedule.StartDate = DateTime.Parse(txt_From_date.Text).ToString("MM/dd/yyyy HH:mm:ss");
obj_Schedule.EndDate = DateTime.Parse(txt_To_date.Text).ToString("MM/dd/yyyy HH:mm:ss");
obj_Schedule.Hub_ID = ddl_Hub.SelectedValue;
obj_Schedule.UserID = string.IsNullOrEmpty(txtEmployeeID.Text) ? string.Empty : txtEmployeeID.Text;

INT_Schedule obj_Int_Schedule = new INT_Schedule();
ArrayList dsRecords = obj_Int_Schedule.GetAllImportedUser_Records(obj_Schedule, PageToDisplay, PageSize);

-----------------------i get 10 records--------each record having 7 column---------------------

now i want to convert this array list to dataset.

how to do it ?

推荐答案

这不是太难了 - ArrayList实现了IList,所以看一下这个技巧:将列表转换为DataTable [ ^ 它应该直接给你一个DataTable - 但是你可能必须转换ArrayList或将它转换为(因为它是强类型的,所以更好,更好)Li st first。

我没有尝试使用ArrayList(因为它们已经过时了,我不使用它们)但它应该可以工作,或者给你一个良好的开端。
It's not too dificult - ArrayList implements IList, so have a look at this tip: Converting a List to a DataTable[^] It should give you a DataTable directly - but you may have to cast the ArrayList or convert it to a (much, much better becasue it is strongly typed) List first.
I haven't tried it with an ArrayList (because they are badly outdated and I don't use them) but it should work, or give you a good start.


这篇关于将arraylist转换为数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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