如何将Ienumerable()转换为字符串? [英] How to convert Ienumerable() to string?

查看:815
本文介绍了如何将Ienumerable()转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个像这样的代码,iam将该字符串值绑定到dropdownlist。



string test = ds.Tables [0] .AsEnumerable() .Where(x => x.Field< int>(Id)== lbl.Text).Select(z => z.Field< string>(Description))。ToString();



Drpdwn.Items.Add(测试);



但执行时它会像这样绑定,



System.Data.EnumerableRowCollection'1 [System.String]



如何解决此问题?在此先感谢。 。

Hi all,i having a code like this and iam binding that string value to dropdownlist.

string test = ds.Tables[0].AsEnumerable().Where(x => x.Field<int>("Id") == lbl.Text).Select(z => z.Field<string>("Description")).ToString();

Drpdwn.Items.Add(test);

but when execution it binds like this,

System.Data.EnumerableRowCollection'1[System.String]

How to fix this?Thanks in Advance..

推荐答案

循环收集并将其添加到下拉项目。

Loops through the collection and add it to the dropdown items.
var items = ds.Tables[0].AsEnumerable().Where(x => x.Field("Id") == lbl.Text).Select(z => z.Field("Description")).ToList();

foreach(var i in items)
{
    Drpdwn.Items.Add(i.ToString());
}





-KR



-KR


这篇关于如何将Ienumerable()转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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