I have the following code:
<asp:FormView runat="server">
<ItemTemplate>
</ItemTemplate>
<FooterTemplate>
<div>
<hr/>
<uc1:Footer runat="server" ID="Footer" />
</div>
</FooterTemplate>
</asp:FormView>
In Footer.ascx I have:
<dx:ASPxLabel ID="lbl" runat="server" Font-Italic="True" Font-Size="10px"></dx:ASPxLabel>
I want to access my user control FooterDetail from the code behind to set lbl value.
How can'I do this.
Thanks.
First you need to provide a property that returns the Label
of the UserControl
or better just it's Text
. Then you can use the FormView
's FooterRow
property and FindControl
to get it:
var uc = (UserControlTypeName)FormView1.FooterRow.FindControl("Footer");
uc.Value = "New Value";
Here's the property in your UserControl
:
public string Value
{
get { return lbl.Text; }
set { lbl.Text = value; }
}