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

SCRIPT7002: XMLHttpRequest: Error 0x800c0007, No data is available for the requested resource.

9 Answers 389 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bernard
Top achievements
Rank 2
Bernard asked on 20 Jul 2013, 05:13 AM
Hi All,

I'm currently facing a very frustating and untraceable bug with my Telerik web app as the web controls did not show any exceptions at all. I am able to insert and delete the records on the grid but CANNOT EDIT them. I hope someone can shed some light into my problem. here's the code that I am using...

ASPX

<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
          <AjaxSettings>
               <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                         <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
               </telerik:AjaxSetting>
          </AjaxSettings>
     </telerik:RadAjaxManager>
 
    <telerik:RadGrid ID="RadGrid1"
        GridLines="None"
        AutoGenerateColumns="false"
        PageSize="10"
        AllowPaging="true"
        AllowSorting="true"
        runat="server"
        DataSourceID="MasterViewDataSource"
        OnItemDataBound="OnItemDataBoundHandler"
        AllowAutomaticInserts="True"
        AllowAutomaticUpdates="true"
        AllowAutomaticDeletes="true"
        ShowStatusBar="true">
        <PagerStyle Mode="NextPrevAndNumeric" />
            <MasterTableView ShowFooter="false" DataKeyNames="TrxId" EditMode="InPlace" CommandItemDisplay="TopAndBottom">
                <Columns>
                    <telerik:GridBoundColumn DataField="TrxId" HeaderText="Trx No." ReadOnly="true"/>
                             
                        <telerik:GridTemplateColumn HeaderText="Job Type" ItemStyle-Width="240px">
                              <ItemTemplate>
                                   <%#DataBinder.Eval(Container.DataItem, "TypeName")%>
                              </ItemTemplate>
                              <EditItemTemplate>
                                   <telerik:RadComboBox runat="server" ID="RadComboBox2" DataTextField="TypeName"
                                        DataValueField="TypeId" DataSourceID="CategoriesDataSource" SelectedValue='<%#Bind("TypeId") %>'>
                                   </telerik:RadComboBox>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
 
                        <telerik:GridTemplateColumn UniqueName="ObjId" HeaderText="Container No."
                            SortExpression="ObjSN">
                            <FooterTemplate>Template footer</FooterTemplate>
                            <FooterStyle VerticalAlign="Middle" HorizontalAlign="Center" />
                                <ItemTemplate>
                                    <%#DataBinder.Eval(Container.DataItem, "ObjSN")%>
                                </ItemTemplate>
 
                            <EditItemTemplate>
                                <telerik:RadComboBox runat="server" ID="RadComboBox1" EnableLoadOnDemand="True" DataTextField="ObjSN"
                                    OnItemsRequested="RadComboBox1_ItemsRequested" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"
                                    DataValueField="ObjId" AutoPostBack="true" HighlightTemplatedItems="true" Height="140px" Width="220px"
                                    DropDownWidth="300px">
                                        <HeaderTemplate>
                                            <ul>
                                                <li class="col1">Container No.</li>
                                                <li class="col2">Container Type</li>
                                           </ul>
                                        </HeaderTemplate>
                                        
                                        <ItemTemplate>
                                            <ul>
                                                <li class="col1">
                                                    <%# DataBinder.Eval(Container, "Text")%>
                                                </li>
                                                <li class="col2">
                                                     <%# DataBinder.Eval(Container, "Attributes['ObjType']")%>
                                                </li>
                                           </ul>
                                      </ItemTemplate>
                                 </telerik:RadComboBox>
                            </EditItemTemplate>
                       </telerik:GridTemplateColumn>
                        
                       <telerik:GridTemplateColumn HeaderText="STCPO">
                            <ItemTemplate>
                                 <%#DataBinder.Eval(Container.DataItem, "StateName")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                 <telerik:RadComboBox runat="server" ID="RadComboBox3" DataTextField="StateName"
                                      DataValueField="StateId" DataSourceID="LoadStatesDataSource" SelectedValue='<%#Bind("StateId") %>'>
                                 </telerik:RadComboBox>
                            </EditItemTemplate>
                       </telerik:GridTemplateColumn>
                             
                       <telerik:GridTemplateColumn HeaderText="Voy. No.">
                            <ItemTemplate>
                                 <%#DataBinder.Eval(Container.DataItem, "VoyName")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                 <telerik:RadComboBox runat="server" ID="RadComboBox4" DataTextField="VoyName"
                                      DataValueField="VoyId" DataSourceID="VoyagesDataSource" SelectedValue='<%#Bind("VoyId") %>'>
                                 </telerik:RadComboBox>
                            </EditItemTemplate>
                       </telerik:GridTemplateColumn>
 
                       <telerik:GridTemplateColumn HeaderText="Shipper">
                            <ItemTemplate>
                                 <%#DataBinder.Eval(Container.DataItem, "Shipr")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                 <telerik:RadComboBox runat="server" ID="RadComboBox5" DataTextField="Shipr" MinFilterLength="4"
                                     OnItemsRequested="RadComboBox5_ItemsRequested" EnableLoadOnDemand="true"
                                     DataValueField="ShipprId" OnSelectedIndexChanged="RadComboBox5_SelectedIndexChanged" 
                                     SelectedValue='<%#Bind("ShiprId") %>'>
                                 </telerik:RadComboBox>
                            </EditItemTemplate>
                       </telerik:GridTemplateColumn>
 
                       <telerik:GridTemplateColumn HeaderText="Consignee">
                            <ItemTemplate>
                                 <%#DataBinder.Eval(Container.DataItem, "Cons")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                 <telerik:RadComboBox runat="server" ID="RadComboBox6" DataTextField="Cons"
                                     OnItemsRequested="RadComboBox6_ItemsRequested" EnableLoadOnDemand="true"
                                     DataValueField="ConsId" OnSelectedIndexChanged="RadComboBox6_SelectedIndexChanged"
                                     SelectedValue='<%#Bind("ConsId") %>'>
                                 </telerik:RadComboBox>
                            </EditItemTemplate>
                      </telerik:GridTemplateColumn>
 
                      <telerik:GridBoundColumn DataField="TrxWeight" HeaderText="GWT" UniqueName="TrxWeight"/>
 
                      <telerik:GridBoundColumn DataField="TrxSeal" HeaderText="Seal No." UniqueName="TrxSeal"/>
 
                      <telerik:GridBoundColumn DataField="TrxRemarks" HeaderText="Remarks" UniqueName="TrxRemarks"/>
 
                      <telerik:GridTemplateColumn HeaderText="Bill To">
                            <ItemTemplate>
                                 <%#DataBinder.Eval(Container.DataItem, "BillCompany")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                 <telerik:RadComboBox runat="server" ID="RadComboBox7" DataTextField="BillCompany"
                                      DataValueField="BillId" DataSourceID="BillingDataSource" SelectedValue='<%#Bind("BillId") %>'>
                                 </telerik:RadComboBox>
                            </EditItemTemplate>
                      </telerik:GridTemplateColumn>
                              
                      <telerik:GridEditCommandColumn FooterText="EditCommand footer" UniqueName="EditCommandColumn"
                           HeaderText="Edit" HeaderStyle-Width="100px" UpdateText="Update">
                      </telerik:GridEditCommandColumn>
 
                     <telerik:GridClientDeleteColumn ConfirmTextFields="TrxId" ConfirmTextFormatString="Are you sure you want to delete transaction No. {0:0000}?"
                           HeaderStyle-Width="35px" ButtonType="ImageButton" ImageUrl="Delete.gif">
                     </telerik:GridClientDeleteColumn>
 
                  </Columns>
             </MasterTableView>
        </telerik:RadGrid>
         
   <asp:SqlDataSource ID="MasterViewDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ZEUS %>"
         SelectCommand="SELECT TransactsData.TrxId, TransactsData.TypeId, TransactsData.StateId, TransactsData.ObjId, TransactsData.VoyId,
                               TransactsData.BillId, TransactsData.TrxWeight, TransactsData.TrxSeal, TransactsData.ShiprId, TransactsData.ConsId,
                               a1.CustName AS Shipr, a2.CustName AS Cons, ObjectsData.ObjSN, ObjectsData.ObjType, 
                               WorkTypes.TypeName,  BillingData.BillCompany, LoadStates.StateName, VoysData.VoyName, VoysData.VoyDate
                         
                        FROM   TransactsData INNER JOIN
                               Customers AS a1 ON a1.CustId = TransactsData.ShiprId INNER JOIN
                               Customers AS a2 ON a2.CustId = TransactsData.ConsId INNER JOIN
                               BillingData ON TransactsData.BillId = BillingData.BillId INNER JOIN
                               WorkTypes ON TransactsData.TypeId = WorkTypes.TypeId INNER JOIN
                               ObjectsData ON TransactsData.ObjId = ObjectsData.ObjId INNER JOIN
                               LoadStates ON TransactsData.StateId = LoadStates.StateId INNER JOIN
                               VoysData ON TransactsData.VoyId = VoysData.VoyId"
                  
         InsertCommand="INSERT INTO [TransactsData] ([TypeId], [StateId], [ObjId], [VoyId], [ShiprId], [ConsId], [TrxWeight], [TrxSeal],
                                    [TrxRemarks], [BillId], [TimeCreated])
             
                             VALUES (@TypeId, @StateId, @ObjId, @VoyId, @ShiprId, @ConsId, @TrxWeight, @TrxSeal, @TrxRemarks, @BillId, GETDATE())"
                  
        UpdateCommand="UPDATE   [TransactsData] SET [TypeId] = @TypeId, [StateId] = @StateId, [ObjId] = @ObjId,
                                [VoyId] = @VoyId, [ShiprId] = @ShiprId, [ConsId] = @ConsId, [TrxWeight] = @TrxWeight,
                                [TrxSeal] = @TrxSeal, [TrxRemarks] = @TrxRemarks, [BillId] = @BillId, [TimeUpdated] = GETDATE()
                        WHERE   [TrxId] = @TrxId"
 
        DeleteCommand="DELETE FROM [TransactsData] WHERE [TrxId] = @TrxId">
                  
        <InsertParameters>
            <asp:Parameter Name="TrxId" Type="Int64" />
            <asp:SessionParameter SessionField="ObjId" Name="ObjId" Type="Int64" />
            <asp:Parameter Name="TypeId" Type="Int32" />
            <asp:Parameter Name="StateId" Type="Int32" />
            <asp:Parameter Name="VoyId" Type="Int64" />
            <asp:Parameter Name="ShiprId" Type="Int64" />
            <asp:Parameter Name="ConsId" Type="Int64" />
            <asp:Parameter Name="TrxWeight" Type="Int32" />
            <asp:Parameter Name="TrxSeal" Type="String" />
            <asp:Parameter Name="TrxRemarks" Type="String" />
            <asp:Parameter Name="BillId" Type="Int32" />
            <asp:Parameter Name="TimeCreated" Type="DateTime" />
        </InsertParameters>
 
        <UpdateParameters>
            <asp:Parameter Name="TrxId" Type="Int64" />
            <asp:SessionParameter SessionField="ObjId" Name="ObjId" Type="Int64" />
            <asp:Parameter Name="TypeId" Type="Int32" />
            <asp:Parameter Name="StateId" Type="Int32" />
            <asp:Parameter Name="VoyId" Type="Int64" />
            <asp:Parameter Name="ShiprId" Type="Int64" />
            <asp:Parameter Name="ConsId" Type="Int64" />
            <asp:Parameter Name="TrxWeight" Type="Int32" />
            <asp:Parameter Name="TrxSeal" Type="String" />
            <asp:Parameter Name="TrxRemarks" Type="String" />
            <asp:Parameter Name="BillId" Type="Int32" />
            <asp:Parameter Name="TimeUpdated" Type="DateTime" />
        </UpdateParameters>
 
       <DeleteParameters>
           <asp:Parameter Name="TrxId" Type="Int64" />
       </DeleteParameters>
    </asp:SqlDataSource>
  
    <asp:SqlDataSource ID="CategoriesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ZEUS %>"
        SelectCommand="SELECT [TypeId], [TypeName] FROM [WorkTypes]"></asp:SqlDataSource>
     
    <asp:SqlDataSource ID="LoadStatesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ZEUS %>"
          SelectCommand="SELECT [StateId], [StateName] FROM [LoadStates]"></asp:SqlDataSource>
 
    <asp:SqlDataSource ID="VoyagesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ZEUS %>"
          SelectCommand="SELECT [VoyId], [VoyName] FROM [VoysData]"></asp:SqlDataSource>
 
    <asp:SqlDataSource ID="BillingDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ZEUS %>"
          SelectCommand="SELECT [BillId], [BillCompany] FROM [BillingData]"></asp:SqlDataSource>
</asp:Content>

C# Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using Telerik.Web.UI;
 
namespace TMSv2
{
    public partial class TestBed : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        //GridEvents
 
        protected void OnItemDataBoundHandler(object sender, GridItemEventArgs e)
        {
            if (e.Item.IsInEditMode)
            {
                GridEditableItem item = (GridEditableItem)e.Item;
    
                 
 
                if (!(e.Item is IGridInsertItem))
                {
                     
                    RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox1");
 
                    RadComboBoxItem selectedItem = new RadComboBoxItem();
                    selectedItem.Text = ((DataRowView)e.Item.DataItem)["ObjSN"].ToString();
                    selectedItem.Value = ((DataRowView)e.Item.DataItem)["ObjId"].ToString();
                    selectedItem.Attributes.Add("ObjType", ((DataRowView)e.Item.DataItem)["ObjType"].ToString());
 
                    combo.Items.Add(selectedItem);
 
                    selectedItem.DataBind();
 
                    Session["ObjId"] = selectedItem.Value;
                }
                 
            }
        }
 
        // ComboboxEvents
 
        protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            string sql = "SELECT [ObjId], [ObjSN], [ObjType], [ObjOID] FROM [ObjectsData]  WHERE ObjSN LIKE @ObjSN + '%'";
            SqlDataAdapter adapter = new SqlDataAdapter(sql,
                ConfigurationManager.ConnectionStrings["ZEUS"].ConnectionString);
            adapter.SelectCommand.Parameters.AddWithValue("@ObjSN", e.Text);
 
            DataTable dt = new DataTable();
            adapter.Fill(dt);
 
            RadComboBox comboBox = (RadComboBox)sender;
 
            comboBox.Items.Clear();
 
            foreach (DataRow row in dt.Rows)
            {
                RadComboBoxItem item = new RadComboBoxItem();
                item.Text = row["ObjSN"].ToString();
                item.Value = row["ObjId"].ToString();
                item.Attributes.Add("ObjType", row["ObjType"].ToString());
 
                comboBox.Items.Add(item);
 
                item.DataBind();
            }
        }
 
        protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Session["ObjId"] = e.Value;
        }
 
        protected void RadComboBox5_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            string sql = "SELECT [CustId], [CustName] FROM [Customers] WHERE CustName LIKE @CustName + '%'";
            var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ZEUS"].ConnectionString);
            var cmd = new SqlCommand(sql, con);
            var reader = default(SqlDataReader);
 
            cmd.Parameters.AddWithValue("@CustName", e.Text);
 
            try
            {
                con.Open();
                reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                var obj = default(object);
                RadComboBox comboBox = (RadComboBox)sender;
                while (reader.Read())
                {
                    obj = reader["CustId"];
                    var id = obj == DBNull.Value ? 0 : Convert.ToInt64(obj);
 
                    obj = reader["CustName"];
                    var name = obj == DBNull.Value ? string.Empty : Convert.ToString(obj);
 
                    RadComboBoxItem item = new RadComboBoxItem();
                    item.Text = name;
                    item.Value = id.ToString();
                    comboBox.Items.Add(item);
                }
            }
            finally
            {
                if (reader != null && !reader.IsClosed) reader.Close();
                if (con != null && con.State == ConnectionState.Open) con.Close();
            }
        }
 
        protected void RadComboBox5_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Session["CustId"] = e.Value;
        }
 
        protected void RadComboBox6_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            string sql = "SELECT [CustId], [CustName] FROM [Customers] WHERE CustName LIKE @CustName + '%'";
            var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ZEUS"].ConnectionString);
            var cmd = new SqlCommand(sql, con);
            var reader = default(SqlDataReader);
 
            cmd.Parameters.AddWithValue("@CustName", e.Text);
 
            try
            {
                con.Open();
                reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                var obj = default(object);
                RadComboBox comboBox = (RadComboBox)sender;
                while (reader.Read())
                {
                    obj = reader["CustId"];
                    var id = obj == DBNull.Value ? 0 : Convert.ToInt64(obj);
 
                    obj = reader["CustName"];
                    var name = obj == DBNull.Value ? string.Empty : Convert.ToString(obj);
 
                    RadComboBoxItem item = new RadComboBoxItem();
                    item.Text = name;
                    item.Value = id.ToString();
                    comboBox.Items.Add(item);
                }
            }
            finally
            {
                if (reader != null && !reader.IsClosed) reader.Close();
                if (con != null && con.State == ConnectionState.Open) con.Close();
            }
        }
 
        protected void RadComboBox6_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Session["CustId"] = e.Value;
        }
    }
}






9 Answers, 1 is accepted

Sort by
0
Bernard
Top achievements
Rank 2
answered on 22 Jul 2013, 10:52 AM
ideas anyone?
0
Konstantin Dikov
Telerik team
answered on 24 Jul 2013, 05:14 PM
Hello Bernard,

Thank you for contacting us.

Since that error occurs only on item edit I could suggest you to remove the following part in OnItemDataBoundHandler event handler in order to determine if this is causing the issue:
if (!(e.Item is IGridInsertItem))
                {
                      
                    RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox1");
  
                    RadComboBoxItem selectedItem = new RadComboBoxItem();
                    selectedItem.Text = ((DataRowView)e.Item.DataItem)["ObjSN"].ToString();
                    selectedItem.Value = ((DataRowView)e.Item.DataItem)["ObjId"].ToString();
                    selectedItem.Attributes.Add("ObjType", ((DataRowView)e.Item.DataItem)["ObjType"].ToString());
  
                    combo.Items.Add(selectedItem);
  
                    selectedItem.DataBind();
  
                    Session["ObjId"] = selectedItem.Value;
                }

You could also try removing all data binds for the RadComboBoxItems.

Additionally, I will suggest you take a look at our online demo for ComboBox: "Load on Demand Modes".

Please try the above and get back to us if it does not helps you with the issue. 
 
Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Bernard
Top achievements
Rank 2
answered on 24 Jul 2013, 10:10 PM
Thanks for your response, setting the Shipper and Consignee column to read only seems to fix the edit mode issue however another type of issue arises, the data that were inserted while in edit mode did not get reflected on the database. The grid still retains the old values after editing... 
0
Bernard
Top achievements
Rank 2
answered on 25 Jul 2013, 01:55 AM
Is there any sample on radgrid with load on demand radcomboboxes similar to my setup??
0
Konstantin Dikov
Telerik team
answered on 29 Jul 2013, 02:40 PM
Hi Bernard,

Thank you for getting back to us.

An example with RadGrid with load on demand RadComboBox (with very similar scenario to yours) is available on this page.

Please examine the demo and see if it helps for your project.
 

Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Bernard
Top achievements
Rank 2
answered on 30 Jul 2013, 07:34 AM
Thank You for your response Konstantin,

I've gone through that sample several times and found that there's a few stark difference between the sample and my current app. Being having more than 1 LoadOnDemand mode Comboboxes in the same RadGrid, I suspected that this might be the root of the issue however it doesn't seem to be logical, thus i'm still short of viable solution for this issue. going deeper to find out what went wrong proven to be difficult as I don't exactly know how does the telerik internal ajax calls work..   
0
Konstantin Dikov
Telerik team
answered on 02 Aug 2013, 08:44 AM
Hello Bernard,

I am attaching a modified version of the previous demo, this time with two RadComboBox controls with LoadOnDemand mode set to "True".

Please examine it and see what differs from your project.

 

Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
tiffany
Top achievements
Rank 1
answered on 22 Oct 2014, 12:42 AM
Hi,

I have a problem with kendo grid, i got the error every time when loading more than 1142 records. it's ok up to 1142.
                .DataSource(ds => ds
                    .Ajax()
                    .Read(read => read.Action("Accounts_Read", "Account")
                        .Data("searchInfo")
                        )
                    .ServerOperation(false) // Paging, sorting, filtering and grouping will be done client-side
                    .Events(events => events.Error("onError"))
                    .Model(model => model.Id(a => a.AccountID))

here is my example, it will go to "onError" when the records more than 1142, it's very strange.
Can you please help me to figure it out?

Thanks
Tiffany
0
Vladimir Iliev
Telerik team
answered on 22 Oct 2014, 07:36 AM
Hi Sai,

From the provided information it seems that the data for serialization exceeds the default MaxJsonLength which causes error on the server side. For more information on the topic you can check the following help article:

On a side note, I would like to remind you that as a general practice it is accepted to ask different questions in separate support threads / forum posts. In this way it is much easier to follow and concentrate on the particular issue which usually leads to its faster resolving.

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Bernard
Top achievements
Rank 2
Answers by
Bernard
Top achievements
Rank 2
Konstantin Dikov
Telerik team
tiffany
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or