Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Reading Values from FormView Ctrl - Object reference not set to an instance of an object.

Reply
Thread Tools

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

 
 
Prakash
Guest
Posts: n/a
 
      12-14-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Object reference not set to an instance of an object" Weird thing happens with reference a link nguyentrongkha@gmail.com ASP .Net 1 09-20-2007 09:46 PM
Reading Values from FormView Ctrl - Object reference not set to an instance of an object. Prakash ASP .Net Web Controls 0 12-14-2006 07:37 AM
Error:Object reference not set to an instance of an object. Suresh Kojhani ASP .Net 1 07-29-2004 12:10 PM
Error !Object reference not set to an instance of an object. !!! Help Parthiv Joshi ASP .Net 2 07-02-2004 10:28 AM
Object reference not set to an instance of an object. Chris Fink ASP .Net 2 07-03-2003 06:48 PM



Advertisments