错误获取数据表行信息 [英] Error Get DataTable row information

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

问题描述



我想要获取行信息,因为我编写了这样的代码,但显示错误

Hi,

I want to Get Row information for that i wrote code like this but it show the error

DataTable dtBind = (DataTable)ViewState["dtBind"];
DataRow drow = dtBind.Select("Doc_Id=" + Doc_Id.ToString()+"AND DED_Id="+row.ToString());



错误是:无法将类型"System.Data.DataRow []"隐式转换为"System.Data.DataRow".



the error is : cannot implicitly convert type ''System.Data.DataRow[]'' to ''System.Data.DataRow''.

推荐答案

尝试使用:

Try with:

DataRow[] drows = dtBind.Select(string.Format("Doc_Id={0} AND DED_Id={1}", Doc_Id, row));



事实是Select方法返回DataRow 对象的数组.这意味着选择的结果可以大于一个.

您可以轻松地检查drows.Count > 0,ii表示他使用该过滤器找到了东西.通过drows[x]可以轻松访问该行,其中x是数组元素的数量(从0开始).


干杯



The fact is that Select method returns an array of DataRow objects. It means that the result of the select can be more than one.

You can easly that check if drows.Count > 0, ii means that he found something with that filter. Accessing the row is easy as drows[x] where x is a number of array element (which starts from 0).


Cheers


Datatable的Select方法返回一个DataRow数组.
因此您需要使用以下代码.

Select method of Datatable returns an array of DataRow.
so you need to use following code.

DataTable dtBind = (DataTable)ViewState["dtBind"];
DataRow[] drow = dtBind.Select("Doc_Id=" + Doc_Id.ToString()+"AND DED_Id="+row.ToString());


这篇关于错误获取数据表行信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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