I have a formview that has several textboxes inside of tr/td\'s. I\'m trying to get the textboxes by using the .FindControl method but it\'s coming back null. The FormView
Call DataBind();
first. Then FindControl()
abatishchev's answer is right, although I found this variation a bit neater: it avoids having to call DataBind() explicitly.
<asp:FormView ID="fvMember" runat="server" DataSourceID="tblMembers" DefaultMode="Insert" OnDataBound="DataBound">...</asp:FormView>
protected void DataBound(object sender, EventArgs e)
{
if (fvMember.CurrentMode == FormViewMode.Edit)
{
Label lblSubmit = fvMember.FindControl("lblSubmit") as Label;
...
}
}