如何在GridView中使用FindControl for DataRow [英] how to use FindControl for DataRow in GridView

查看:97
本文介绍了如何在GridView中使用FindControl for DataRow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



可以告诉我如何在Gridview中使用FindControl for DataRow。



i将数据绑定到GridView FooterRow,在Add Button上绑定DataRow中的FooterRow数据,最初DataRow为null。



我发现FooterRow像:

数量=((TextBox)GridView1.FooterRow.FindControl(txtQty))。文字;



所以,就像我想要的一样找到DataRow

解决方案

所以如果你想从gridview的datarow中找到任何名为txtQty的控件示例文本框,



你可以为此目的使用Gridview的onRowDataBound方法。>





你可以使用像......





 受保护  void  GridView_RowDataBound( object  sender,GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// 你的代码就在这里..

TextBox lb =(TextBox)(e.Row.Cells [ 0 ]。控制[ 0 ]);

}
}





希望它有用......:)


TextBox box3 =(TextBox)Sales_Grid.Rows [rowIndex] .Cells [cellIndex] .FindControl(ControlName);


hello,

can any one tell me that how can use FindControl for DataRow in Gridview.

i have bounded data to GridView FooterRow, on Add Button it bind the FooterRow data in DataRow, initially DataRow in null.

I am find the FooterRow like:
Qty = ((TextBox)GridView1.FooterRow.FindControl("txtQty")).Text;

So, in the same way i wanted to find for DataRow

解决方案

So If you wanted to find any control forexample textbox named txtQty from datarow of your gridview,

You can use Gridview's onRowDataBound method for that purpose.>


You can use like.....


protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
//Your code goes here..

TextBox lb = (TextBox)(e.Row.Cells[0].Controls[0]);
           
       }
    }



Hope it will help.... :)


TextBox box3 = (TextBox)Sales_Grid.Rows[rowIndex].Cells[cellIndex].FindControl("ControlName");


这篇关于如何在GridView中使用FindControl for DataRow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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