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

[Solved] Error Refreshing a grid on Change of a dropDownList

4 Answers 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ja
Top achievements
Rank 1
Ja asked on 24 Aug 2011, 09:36 AM
Hello,
I get an error when I choose an item of a drop down list, that rebinds a grid. With some items of the dropdownlist works fine but with others stop working and I get this error on the browser console:
  1. Uncaught TypeError: Cannot read property 'value' of null
    1. Telerik.Web.UI.RadInputExtender.updateValueTelerik.Web.UI.WebResource.axd:5345
    2. Telerik.Web.UI.RadInputExtender._beforeSubmitTelerik.Web.UI.WebResource.axd:5431
    3. Telerik.Web.UI.RadTextBoxExtender._beforeSubmitTelerik.Web.UI.WebResource.axd:5538
    4. Telerik.Web.UI.RadInputManager._beforeSubmitTelerik.Web.UI.WebResource.axd:5483
    5. Telerik.Web.UI.RadInputManager._onSubmitTelerik.Web.UI.WebResource.axd:5479
    6. Telerik.Web.UI.RadInputManager.WebForm_OnSubmitTelerik.Web.UI.WebResource.axd:5494
    7. (anonymous function)Products_OV.aspx:10
    8. Sys.WebForms.PageRequestManager._onFormSubmitTelerik.Web.UI.WebResource.axd:15
    9. Sys.WebForms.PageRequestManager._doPostBackTelerik.Web.UI.WebResource.axd:15
    10. (anonymous function):1

If I disable AJAX, it works fine, but with AJAX problems happens. I also attach the error that I get from the console.


I also put here part of my code:

This is the index change function:
protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
   {
       ProductRepository productRP = new ProductRepository();
       Filters filters = new Filters();
 
       filters.Add(new Filter("Supplier.Id", SupplierId));
       if (ddlCategory.SelectedValue != "All")
           filters.Add(new Filter("Product.ProductCategory.Id", ddlCategory.SelectedValue.ToString()));
 
       IList<SupplierProduct> supplierProducts = productRP.LoadList<SupplierProduct>(filters);
 
       RadGrid1.DataSource = supplierProducts;
 
      // System.Threading.Thread.Sleep(3000);
       RadGrid1.Rebind();
   }


NeedDataSource:
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
  {
 
      ProductRepository productRP = new ProductRepository();
      Filters filters = new Filters();
 
      filters.Add(new Filter("Supplier.Id", SupplierId));
      if(ddlCategory.SelectedValue != "All")
      filters.Add(new Filter("Product.ProductCategory.Id", ddlCategory.SelectedValue.ToString()));
     // filters.Add(new Filter("Active","true"));
     // filters.Add(new Filter("Product.Active", "true"));
      IList<SupplierProduct> supProducts = productRP.LoadList<SupplierProduct>(filters);
 
      RadGrid1.DataSource = supProducts;
  }


Page Load:
protected void Page_Load(object sender, EventArgs e)
    {
         
        SupplierId = Session["SupplierId"].ToString();
        if (String.IsNullOrEmpty(SupplierId))
        {
            Response.Redirect("login.aspx");
        }
 
        if (!Page.IsPostBack){
        ProductRepository productRP = new ProductRepository();
        Filters filters = new Filters();
        filters.Add(new Filter("Supplier.Id", SupplierId));
 
        IList<SupplierProductCategory> SupplierProductCategories = productRP.LoadList<SupplierProductCategory>(filters, "ProductCategory.Description");
 
        IList<ProductCategory> ProductCategories = new List<ProductCategory>();
        foreach (SupplierProductCategory supplierProductCategory in SupplierProductCategories)
        {
            ProductCategories.Add(supplierProductCategory.ProductCategory);
        }
      
        ddlCategory.DataSource = ProductCategories;
        ddlCategory.DataBind();
        }
    }


AjaxSettings:

 <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" 
    ClientEvents-OnRequestStart="mngRequestStarted"
    meta:resourcekey="RadAjaxManager1Resource1">
<AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadInputManager1" />
                    <telerik:AjaxUpdatedControl ControlID="Label1" />
                    <telerik:AjaxUpdatedControl ControlID="RadMenu1" />
                    <telerik:AjaxUpdatedControl ControlID="ddlCategory" />
                    <telerik:AjaxUpdatedControl ControlID="ddlLanguage" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="RadInputManager1" />
                    <telerik:AjaxUpdatedControl ControlID="Label1" />
                    <telerik:AjaxUpdatedControl ControlID="RadMenu1" />
                    <telerik:AjaxUpdatedControl ControlID="ddlCategory" />
                    <telerik:AjaxUpdatedControl ControlID="ddlLanguage" />
                </UpdatedControls>
            </telerik:AjaxSetting>
 
           <%-- ----excel export----------%>
            <telerik:AjaxSetting AjaxControlID="mngBtnExcel">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        <telerik:AjaxUpdatedControl ControlID="mngBtnExcel" />
                    </UpdatedControls>
            </telerik:AjaxSetting>
 
            <%-- ----context menu----------%>
            <telerik:AjaxSetting AjaxControlID="RadMenu1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadMenu1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
 
                <telerik:AjaxSetting AjaxControlID="ddlCategory">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="ddlCategory" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
...

Any idea of why this is happening?
I would appreciate any idea for fixing this problem.

Thank you very much,
Jon


4 Answers, 1 is accepted

Sort by
0
Ja
Top achievements
Rank 1
answered on 24 Aug 2011, 01:48 PM
I have realized that the error goes if I delete the next line from the ItemCreated event:
 numberSetting.TargetControls.Add(new TargetInput(txtBox1.UniqueID, true));


protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
 
       if (e.Item is GridDataItem)
       {
           GridDataItem dataItem = (GridDataItem)e.Item;
            
           TextBox txtBox1 = (TextBox)dataItem.FindControl("txtBoxAreaId");
           NumericTextBoxSetting numberSetting = (NumericTextBoxSetting)RadInputManager1.GetSettingByBehaviorID("NumberBehavior");
          // numberSetting.TargetControls.Add(new TargetInput(txtBox1.UniqueID, true));
....

Any idea of why this can be happening?

Thanks,
Jon
0
Iana Tsolova
Telerik team
answered on 29 Aug 2011, 02:11 PM
Hello Ja,

The error receive is a javascript error. Do you have any custom javascript on the page? And does it make any difference if you disable ajax?

Best wishes,
Iana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Harini
Top achievements
Rank 1
answered on 19 Apr 2013, 02:35 PM
I am getting exact same error but when I rebind the grid after paging from a DataPager control. Did you'll find a solution to this?
0
Harini
Top achievements
Rank 1
answered on 19 Apr 2013, 06:28 PM
That error went away after I followed this post
http://www.telerik.com/community/forums/aspnet-ajax/input/validation-disappearing-in-radinputmanager-controls-tied-to-the-radajaxmanager-on-loss-of-focus-onblur.aspx

and changed the ajaxification part. I implemeneted RadAjaxManager instead of RadAjaxPanel.
Tags
Grid
Asked by
Ja
Top achievements
Rank 1
Answers by
Ja
Top achievements
Rank 1
Iana Tsolova
Telerik team
Harini
Top achievements
Rank 1
Share this question
or