从数据集中获取值 [英] getting the value from dataset

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

问题描述

DataSet NAME_DATASET = new DataSet();
                NAME_DATASET.ReadXml(myXMLfile);
                NameDropDownList.DataSource = NAME_DATASET;
                NameDropDownList.DataTextField = "NAME";
                NameDropDownList.DataValueField = "ID";
                NameDropDownList.DataBind();
                NameDropDownList.Items.Insert(0, new ListItem("--Select--", "0"));



在上面的代码中,数据集已分配给数据源.那应该意味着数据集是相同类型的数据源.数据集以表的形式存储数据.现在,我需要遍历并从我的下拉列表中获取ID.但是在我的示例中,数据集位于数据源中,但数据源没有表的成员或属性.因此,如何从datsource中获取ID.



In the above code the dataset is assigned to datasource. That should mean dataset is the same type of datasource. The dataset is storing data in the form of tables. Now I need to loop through and take the id from my dropdownlist. But in my example data set is in datasource but datasource doesn''t have a member or property of table. So how can I get the id from the datsource.

推荐答案


您的ReadXml(myXMLfile)结果是否进入多个表?

如果不是

Hi
Is your ReadXml(myXMLfile) results into multiple tables?

If not

DataTable NAME_DATATABLE = new DataTable();
NAME_DATATABLE .ReadXml(myXMLfile);
NameDropDownList.DataSource = NAME_DATATABLE;



如果结果为多个表



If it results multiple tables

NameDropDownList.DataSource = NAME_DATASET["TableName"];


这篇关于从数据集中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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