Click here to Skip to main content
12,406,592 members (51,554 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
E.g We use following code to find each control on page

foreach (System.Web.UI.Control c in Page.Controls)
 {
 
}

we can check control by Id ,in Following Code

foreach (System.Web.UI.Control c in Page.Controls)
 {
 
if (c.ID == "ddlLandCost")
           {
           }
}


but if I want to find control which is in gridview by same above code, guys if you have any idea please help...As my logic is depend on above code.i dont want to use any rowdatabound event...
Posted 10-Dec-12 23:14pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

foreach (System.Web.UI.Control c in Page.Controls)
 {
Control objChild=((Control)Page.Controls[i]);
 
}
 
use like this..
  Permalink  
Comments
Member 8314670 11-Dec-12 6:28am
   
hey thnx for rply,
i didnt get your solution what is "i" in here,and i want find control inside gridview by name
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

you can find your controls like below:
(e.Item.FindControl("txtInsuranceTypeDescription") as SysXTextBox).Text;
where txtInsuranceTypeDescription is a textbox control.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160730.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100