P
Prakash
Hi all,
I am getting an error message "Object reference not set to an instance
of an object." when i try to read values that are inside FormView
control. I am just trying to read the values displayed in a formview
control to be used elsewhere in the same page. Below is the code that
i've used
in the aspx page,
<asp:FormView ID="fvProject" DataSourceID="SqlDataSource3"
OnItemCreated="fvProject_ItemCreated" runat="server" >
<ItemTemplate>
Domain:
<asp:Label ID="domainLabel" runat="server" Text='<%#
Bind("domain") %>'></asp:Label><br />
</ItemTemplate>
</asp:FormView>
in the aspx.cs page,
protected void fvProject_ItemCreated(object sender, EventArgs e)
{
DataRowView DRV = (DataRowView)fvProject.DataItem;
string myString = DRV["domain"].ToString();
//This is where the error occurs
}
i've also tried manually assigning the event handler,
protected override void OnInit(EventArgs e)
{
fvProject.ItemCreated += new
EventHandler(fvProject_ItemCreated);
base.OnInit(e);
}
but still its not working,
Can someone please tell me how to read values displayed in a FormView
contorl.
Thanks,
Prakash
I am getting an error message "Object reference not set to an instance
of an object." when i try to read values that are inside FormView
control. I am just trying to read the values displayed in a formview
control to be used elsewhere in the same page. Below is the code that
i've used
in the aspx page,
<asp:FormView ID="fvProject" DataSourceID="SqlDataSource3"
OnItemCreated="fvProject_ItemCreated" runat="server" >
<ItemTemplate>
Domain:
<asp:Label ID="domainLabel" runat="server" Text='<%#
Bind("domain") %>'></asp:Label><br />
</ItemTemplate>
</asp:FormView>
in the aspx.cs page,
protected void fvProject_ItemCreated(object sender, EventArgs e)
{
DataRowView DRV = (DataRowView)fvProject.DataItem;
string myString = DRV["domain"].ToString();
//This is where the error occurs
}
i've also tried manually assigning the event handler,
protected override void OnInit(EventArgs e)
{
fvProject.ItemCreated += new
EventHandler(fvProject_ItemCreated);
base.OnInit(e);
}
but still its not working,
Can someone please tell me how to read values displayed in a FormView
contorl.
Thanks,
Prakash