So I have this FormView which should only have 1 record for editing:
<asp:FormView ID="fmv_accountDetail" runat="server" DataKeyNames="UserID"
DataSourceID="sds_accountDetail" DefaultMode="Edit"
emptydatatext="No employees found."
onitemcommand="fmv_accountDetail_ItemCommand" >
<EditItemTemplate>
<asp:Label ID="lbl_UserID" runat="server" Text='<%# Eval("UserID") %>' Visible="false"></asp:Label>
<asp:Label ID="lbl_CustomerName" runat="server" Text='<%# Eval("customerName") %>' Visible="false"></asp:Label>
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
</asp:FormView>
How do I get the lbl_CustomerName in C#? I would like to populate other labels with this value on the page.
Here is what I have been trying, but it say null error exception:
(fmv_accountDetail.FindControl("lbl_CustomerName") as Label).Text;
Found the problem, and it was really easy too: