Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net access control in FormView ItemTemplate

I have a form view with an item template with a control inside, is it possible to access that control OnDatabound so I can bind the control with data. I'm using a panel as an example here.

<cc1:LOEDFormView ID="FireFormView" runat="server" DataSourceID="DataSourceResults"     CssClass="EditForm" DataKeyNames="id" OnDatabound="FireFromView_Databound">
<ItemTemplate>

<asp:Panel ID ="pnl" runat="server"></asp:Panel>

</ItemTemplate>

</cc1:LOEDFormView>
like image 275
Funky Avatar asked Dec 17 '22 14:12

Funky


1 Answers

You have to take care the item mode as well in which your control exist which you want to find. Like if your control in Item Template, then it would be like..

if (FormView1.CurrentMode == FormViewMode.ReadOnly)
{

  Panel pnl = (Panel)FormView1.FindControl("pnl");
}
like image 198
Muhammad Akhtar Avatar answered Dec 31 '22 16:12

Muhammad Akhtar