Click here to Skip to main content
Rate this: bad
good
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 at 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
0 OriginalGriff 205
1 ProgramFOX 120
2 Richard MacCutchan 100
3 ChauhanAjay 100
4 kbrandwijk 90
0 Sergey Alexandrovich Kryukov 9,050
1 OriginalGriff 8,151
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 11 Dec 2012
Copyright © CodeProject, 1999-2014
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