Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Contributor
3052 Points
2405 Posts
Sep 04, 2009 09:40 PM|LINK
What is wrong with this:
Label
lblcost = (Label)gv_sku_details.FindControl("lblCost"); TextBox txtcost = (TextBox)gv_sku_details.FindControl("txtCost");
decimal lcost = decimal.Parse(lblcost.Text); decimal dcost = decimal.Parse(txtcost.Text);
///////////////////////////////////////
I get this error when i call my method
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Line 142: decimal lcost = decimal.Parse(lblcost.Text); Line 143: decimal dcost = decimal.Parse(txtcost.Text);
And here is my ASPX code:
<asp:TemplateField HeaderText="COST"> <ItemTemplate> <asp:Label ID="lblCost" runat="server" Text='<%# Bind("tot_cost") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Label ID="lblCost" runat="server" Text='<%# Bind("tot_cost") %>' Visible="false"></asp:Label> <asp:TextBox ID="txtCost" runat="server" Text='<%# Bind("tot_cost") %>' CssClass="BorderedTextBox" Width="80"></asp:TextBox> </EditItemTemplate> </asp:TemplateField>
cubangt
Contributor
3052 Points
2405 Posts
What am i doing wrong?
Sep 04, 2009 09:40 PM|LINK
What is wrong with this:
Label
lblcost = (Label)gv_sku_details.FindControl("lblCost");
TextBox txtcost = (TextBox)gv_sku_details.FindControl("txtCost");
decimal lcost = decimal.Parse(lblcost.Text);
decimal dcost = decimal.Parse(txtcost.Text);
///////////////////////////////////////
I get this error when i call my method
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Line 142: decimal lcost = decimal.Parse(lblcost.Text);
Line 143: decimal dcost = decimal.Parse(txtcost.Text);
And here is my ASPX code:
<asp:TemplateField HeaderText="COST">
<ItemTemplate>
<asp:Label ID="lblCost" runat="server" Text='<%# Bind("tot_cost") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblCost" runat="server" Text='<%# Bind("tot_cost") %>' Visible="false"></asp:Label>
<asp:TextBox ID="txtCost" runat="server" Text='<%# Bind("tot_cost") %>' CssClass="BorderedTextBox" Width="80"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
---------------------
Mark as Answered if it helped