For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET Webcontrols > December 2006 > Reading Values from FormView Ctrl - Object reference not set to an instance of an obj









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Reading Values from FormView Ctrl - Object reference not set to an instance of an obj
Prakash

2006-12-14, 4:18 am

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com