This is a migrated thread and some comments may be shown as answers.

How to find textbox control inside itemtemplate

2 Answers 248 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vincent
Top achievements
Rank 1
vincent asked on 27 Sep 2011, 03:09 PM
I have a textbox control (textbox1) within the itemtemplate of a radgrid and this radgrid lies within a contentplaceholder of a master page.

How can I use findcontrol to find this textbox1 inside the page_load event ?

Thank you

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 27 Sep 2011, 05:20 PM
Hello,

you are not able to get this thing in Page_load.
Please do your functionality in Page_Prerender.

please below link for page life cycle
General Page Life-Cycle Stages

<telerik:GridTemplateColumn >
                       <ItemTemplate>
                           <asp:TextBox ID="txtAmount" runat="server"></asp:TextBox>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>

protected void Page_PreRender(object sender, EventArgs e)
        {
            foreach (GridDataItem item in RadGrid1.Items)
            {
                TextBox txtAmount = item.FindControl("txtAmount") as TextBox;
                // access textbox here
            }
        }


FYI page_load event fire first then after it fire grid's event (Column created,item created...etc)

Thanks,
Jayesh Goyani
0
vincent
Top achievements
Rank 1
answered on 27 Sep 2011, 05:58 PM
Hi Jayesh,

Thanks and appreciate your help very much
Tags
Grid
Asked by
vincent
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
vincent
Top achievements
Rank 1
Share this question
or