This is a migrated thread and some comments may be shown as answers.

Radgrid edit mode - Object reference not set to an instance of an object.

0 Answers 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jagat
Top achievements
Rank 1
Jagat asked on 06 Feb 2017, 06:15 PM

Hi All,

I have a radnumerictextbox within a grid. When this value is changed in edit mode, i want to perform some calculations.

I keep getting object reference not set to a instance on this line as well as the one after that.

  famIncome = Convert.ToDouble(((RadNumericTextBox)dataItem.FindControl("rntxtAnnualIncome")).Value );

Not sure what i am missing here.

Let me know how to get those values.

 

 

protected void rntxtAnnualIncome_TextChanged(object sender, EventArgs e)
    {
        foreach (GridDataItem dataItem in rg_ProgramApp.EditItems )
        {
            double famIncome;
            int famMembers;
            famIncome = Convert.ToDouble(((RadNumericTextBox)dataItem.FindControl("rntxtAnnualIncome")).Value );
            famMembers = Convert.ToInt32(((RadNumericTextBox)dataItem.FindControl("rntxtFamilymembers")).Text);
        }
    }
 
 
<telerik:GridTemplateColumn UniqueName="FamilyMembers" HeaderText="FamilyMembers">
    <ItemTemplate>
    <asp:Label runat="server" ID="lblFamilyMembers" Text='<%# Bind("FamilyMembers") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <telerik:RadNumericTextBox runat="server" ID="rntxtFamilymembers"   DbValue='<%# Bind("FamilyMembers") %>'
     MaxValue="20" NumberFormat-DecimalDigits="0" ></telerik:RadNumericTextBox>
    </EditItemTemplate>
    </telerik:GridTemplateColumn>
 
<telerik:GridTemplateColumn UniqueName="AnnualIncome" HeaderText="Annual Income">
    <ItemTemplate>
    <asp:Label runat="server" ID="lblAnnualIncome" Text='<%# Bind("AnnualIncome") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
    <telerik:RadNumericTextBox runat="server" ID="rntxtAnnualIncome" Value='<%# Bind("AnnualIncome") %>'
    Type="Currency" NumberFormat-DecimalDigits="2" OnTextChanged="rntxtAnnualIncome_TextChanged" AutoPostBack="true" ></telerik:RadNumericTextBox>
    </EditItemTemplate>
    </telerik:GridTemplateColumn>

 

Thanks in Advance

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Jagat
Top achievements
Rank 1
Share this question
or