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

Discussion in 'ASP .Net' started by Prakash, Dec 14, 2006.

  1. Prakash

    Prakash Guest

    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
     
    Prakash, Dec 14, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Danny

    Implement Ctrl-C, Ctrl-V

    Danny, Aug 14, 2003, in forum: C++
    Replies:
    5
    Views:
    673
    CBFalconer
    Aug 15, 2003
  2. Danny

    Implement Ctrl-C, Ctrl-V

    Danny, Aug 14, 2003, in forum: C Programming
    Replies:
    5
    Views:
    692
    CBFalconer
    Aug 15, 2003
  3. Replies:
    1
    Views:
    515
    Mark Rae [MVP]
    Sep 20, 2007
  4. Replies:
    0
    Views:
    589
  5. Prakash
    Replies:
    0
    Views:
    289
    Prakash
    Dec 14, 2006
Loading...

Share This Page