我想要预先排好所有行并取出单元格并写出来 [英] i want to foreach all rows and take the cell and write out

查看:77
本文介绍了我想要预先排好所有行并取出单元格并写出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach (GridViewRow gvRowAssigment in GridViewAllAssigments.Rows)
            {
var emp_assig_ref = new EMPLOYEES_ASSIGMENT_REFERENCE();
                emp_assig_ref.reference_name = gvRowAssigment.Cells[0].Text;

}





这不起作用我在列中没有任何价值,我一直在谷歌搜索他们





This is not working i get no value in the column , i have been googling al they

emp_assig_ref.reference_name = gvRowAssigment.Cells[0].Value.ToString();





像这样很多网站都说,但是我的intellisense找不到价值,我发现现在找到了价值但当我将foreach更改为foreach(GridviewAllassigment.Rows中的DataGridViewRow gvRowAssigment)



i得到此错误:

无法转换对象键入''System.Web.UI.WebControls.GridViewRow''键入''System.Windows.Forms.DataGridViewRow''。



Like this many site says , but my intellisense cannot find value, i have find out were to find value now but when i change the foreach to " foreach (DataGridViewRow gvRowAssigment in GridviewAllassigment.Rows)

i get this error:
Unable to cast object of type ''System.Web.UI.WebControls.GridViewRow'' to type ''System.Windows.Forms.DataGridViewRow''.

推荐答案


该错误告诉您无法将System.Web.UI.WebControls.GridViewRow强制转换为System.Windows.Forms.DataGridViewRow。

简单地说,将青苹果投入红苹果,虽然它们是苹果,但在某些方面有所不同文本。

使用你的foreach循环来使用System.Web.UI.WebControls.GridViewRow,因为你的GridViewAllAssigments是System.Web.UI.WebControls.GridView。



Hi,
The error is telling you that you cannot cast System.Web.UI.WebControls.GridViewRow to System.Windows.Forms.DataGridViewRow.
In simple words casting green apples to red apples, although they are apple, but different in some context.
use your foreach loop to use System.Web.UI.WebControls.GridViewRow as your GridViewAllAssigments is System.Web.UI.WebControls.GridView.

foreach(System.Web.UI.WebControls.GridViewRow gvRowAssigment in GridViewAllAssigments.Rows)





我希望这会有所帮助。



问候

Jegan



I hope this helps.

Regards
Jegan


这篇关于我想要预先排好所有行并取出单元格并写出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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