The FindControl method of the page class can be used to find any control inside a web form, regardless of its location in the page hierarchy. This includes controls that are nested inside other controls, such as controls within a GridView's TemplateField.
To find a control within a GridView's TemplateField, you can use the following steps:
In your code, you are trying to find the HyperLink control with the ID "hlPlus" within the ItemTemplate of the GridView's TemplateField. To do this, you can use the following code:
foreach (GridViewRow row in grvYourOpportunities.Rows) { if (row.RowType == DataControlRowType.DataRow) { // Get a reference to the HyperLink control. HyperLink hlPlus = (HyperLink)row.FindControl("hlPlus"); // Check if the HyperLink control was found. if (hlPlus != null) { // Do something with the HyperLink control. } } }
This code will iterate through the rows of the GridView and find the HyperLink control with the ID "hlPlus" within the ItemTemplate of the TemplateField. If the control is found, it will be assigned to the hlPlus variable. You can then use the hlPlus variable to do whatever you need to do with the control.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3