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

1 posts, 0 answers
  1. Jagat
    Jagat avatar
    151 posts
    Member since:
    Jan 2011

    Posted 06 Feb 2017 Link to this post

    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

Back to Top