troubleshooting Question

ASP.NET & C# Question: System.NullReferenceException: Object reference not set to an instance of an object.

Avatar of stu29
stu29Flag for United States of America asked on
ASP.NET
8 Comments1 Solution794 ViewsLast Modified:
I'm getting
System.NullReferenceException: Object reference not set to an instance of an object.
when I'm just trying to read a value from a DetailsView on ItemInserting.
[in aspx]
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
            DataKeyNames="BinCategoryID" DataSourceID="SqlDataSource2" 
            Height="50px" Width="125px" OnItemInserting="DetailsView1_ItemInserting" 
            DefaultMode="Insert" onpageindexchanging="DetailsView1_PageIndexChanging">
            <Fields>
...
<InsertItemTemplate>
                        <asp:TextBox ID="tbInsertBinCategory" runat="server" Text='<%# Bind("BinCategory") %>'></asp:TextBox>
                    </InsertItemTemplate>
 
[in code behind]
protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            Label3.Text = e.Values["tbInsertBinCategory"].ToString();  (<- erroring here)
ASKER CERTIFIED SOLUTION
Padre_Corleone

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros