无法将“System.Web.UI.WebControls.GridViewRow”类型的对象强制转换为“System.Web.UI.WebControls.GridView”类型 [英] Unable to cast object of type 'System.Web.UI.WebControls.GridViewRow' to type 'System.Web.UI.WebControls.GridView'

查看:384
本文介绍了无法将“System.Web.UI.WebControls.GridViewRow”类型的对象强制转换为“System.Web.UI.WebControls.GridView”类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有gridview。我已将一些数据输入网格视图。之后我点击了保存按钮。这个事件转到了GetLatestDataFromGrid方法。它给出了错误



Hi,
i have gridview. i have entered some data into grid view. after that i clicked on save button.this event goes to GetLatestDataFromGrid method.there its giving error

protected void SavePlanningGoods()
   {
       
           DataTable lDtLatestInfo;
           lDtLatestInfo = GetLatestDataFromGrid();
}







private DataTable GetLatestDataFromGrid()
   {


       DataTable lDtMenuDisplay = obj.gridTableSchema();
       DataRow lDrMenuDisplay;

       foreach (GridView lgPlanningGoods in gvPlanningGoods.Rows)--here i m getting error
       {
           Label lblsupcat = (Label)lgPlanningGoods.FindControl("lblsupcat");
           TextBox txtYear = (TextBox)lgPlanningGoods.FindControl("txtYear");
           TextBox txtPeriod = (TextBox)lgPlanningGoods.FindControl("txtPeriod");
           DropDownList drpCategory = (DropDownList)lgPlanningGoods.FindControl("drpCategory");

推荐答案

将其改为......

Change it to...
foreach (GridViewRow lgPlanningGoods in gvPlanningGoods.Rows)


这篇关于无法将“System.Web.UI.WebControls.GridViewRow”类型的对象强制转换为“System.Web.UI.WebControls.GridView”类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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