Reading Values from FormView Ctrl - Object reference not set to an instance of an object.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top