Hi,
I want to access in code-behind a label within the ItemTemplate of a
Formview.
<asp:FormView ID="FormView1" runat="server" DataKeyNames="id"
DataSourceID="SqlDataSource1" >
<ItemTemplate>
<asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name")
%>'></asp:Label>
code-behind:
Dim name As String = CType(FormView1.FindControl("nameLabel"), Label).Text
I get the error: "Object reference not set to an instance of an object"
Could somebody tell me what's wrong in my code?
Thanks
Ben
pintu - 27 Jun 2007 10:54 GMT
> Hi,
>
[quoted text clipped - 15 lines]
> Thanks
> Ben
The problem is with the viewstate of the formview control. Just enable
the view state of the control and make sure u are not populating it in
button's click; access it.
Hope this will solve your problem.