Click here to Skip to main content
15,901,001 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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
Posted

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.....


C#
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.... :)
 
Share this answer
 
v2
TextBox box3 = (TextBox)Sales_Grid.Rows[rowIndex].Cells[cellIndex].FindControl("ControlName");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900