Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
30
WebDataGrid with MasterPage
posted

I am following the example from https://www.infragistics.com/community/product_platforms/aspnet/w/aspnet-wiki/49/data-binding-the-webdatagrid-to-common-data-sources to bind to an ObjectDataSource. As it stands, it is working and I am also successful activating the cell editing and row adding behaviors. However, as soon as I use a MasterPage and put this within a Content, I receive "Deserialization failure: Invalid response" warnings on all add or edit actions. I have also added code-behind to assign the datasource dynamically. Can you help? Here is my code:

MASTER PAGE:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<%@ Register assembly="Infragistics35.Web.v10.3, Version=10.3.20103.1013, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.NavigationControls" tagprefix="ig" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">www.w3.org/.../xhtml1-transitional.dtd">
<html xmlns="">www.w3.org/.../xhtml">
<head runat="server">
    <asp:ContentPlaceHolder id="_headPlaceHolder" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
  <form id="form1" runat="server">
    <div class="MenuSection">
      <asp:ContentPlaceHolder id="_menuPlaceHolder" runat="server">
      </asp:ContentPlaceHolder>
    </div>
    <div class="ContentSection">
      <asp:ScriptManager ID="_scriptManager" runat="server"></asp:ScriptManager>
      <asp:ContentPlaceHolder id="_mainPlaceHolder" runat="server"></asp:ContentPlaceHolder>
    </div>
  </form>
</body>
</html>

ASPX PAGE (Default2.aspx):

<%@ Page Title="" Language="C#" AutoEventWireup="true" MasterPageFile="~/Admin/MasterPage.master" CodeFile="Default2.aspx.cs" Inherits="Admin_Default2" %>
<%@ Register assembly="Infragistics35.Web.v10.3, Version=10.3.20103.1013, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.GridControls" tagprefix="ig" %>

<asp:Content ID="_mainContent" ContentPlaceHolderID="_mainPlaceHolder" runat="Server">
  <asp:ScriptManagerProxy ID="_scriptManagerProxy" runat="server">
  </asp:ScriptManagerProxy>
  <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
    SelectMethod="GetAllItems" TypeName="TestEntity"
    DataObjectTypeName="TestEntity" InsertMethod="SaveItem" UpdateMethod="SaveItem"></asp:ObjectDataSource>
  <ig:WebDataGrid ID="WebDataGrid1" runat="server" AutoGenerateColumns="False"
    Height="350px" Width="400px" DataKeyFields="Id">
    <Columns>
      <ig:BoundDataField DataFieldName="Id" Key="Id"><Header Text="Id" /></ig:BoundDataField>
      <ig:BoundDataField DataFieldName="TestProperty" Key="TestProperty"><Header Text="TestProperty" /></ig:BoundDataField>
    </Columns>
    <Behaviors>
      <ig:EditingCore>
        <Behaviors><ig:CellEditing></ig:CellEditing><ig:RowAdding></ig:RowAdding><ig:RowDeleting /></Behaviors>
      </ig:EditingCore>
      <ig:Selection CellClickAction="Row" RowSelectType="Single"></ig:Selection>
      <ig:RowSelectors></ig:RowSelectors>
    </Behaviors>
  </ig:WebDataGrid>
</asp:Content>

CODE-BEHIND:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_Default2 : System.Web.UI.Page
{
    protected void Page_Init(object sender, EventArgs e)
    {
        WebDataGrid1.DataSource = ObjectDataSource1;
    }
}

CUSTOM OBJECT (in App_Code):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public class TestEntity
{
    private static List<TestEntity> _list = new List<TestEntity>();

    public long Id { get; set; }
    public string TestProperty { get; set; }

    static TestEntity()
    {
        _list.Add(new TestEntity() { Id = 1, TestProperty = "A" });
        _list.Add(new TestEntity() { Id = 2, TestProperty = "B" });
    }

    public TestEntity() { }

    public List<TestEntity> GetAllItems() { return _list; }

    public int SaveItem(TestEntity instance)
    {
        int indexFound = -1;
        foreach (TestEntity entity in _list)
            if (entity.Id == instance.Id)
                indexFound = _list.IndexOf(entity);
        if (indexFound > -1) _list[indexFound] = instance;
        else _list.Add(instance);
        return 1;
    }
}
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<%

@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage"

%>

<%

 

@ Register assembly="Infragistics35.Web.v10.3, Version=10.3.20103.1013, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.NavigationControls" tagprefix="ig"

%>

 

<!

 

 

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

 

"">www.w3.org/.../xhtml1-transitional.dtd">

<

 

 

html xmlns

="">www.w3.org/.../xhtml">

<

 

 

head runat

="server">

 

 

 

<asp:ContentPlaceHolder id="_headPlaceHolder" runat="server"></asp:ContentPlaceHolder

 

>

</

 

 

head

>

<

 

 

body

>

 

 

 

<form id="form1" runat

 

="server">

 

 

 

<div class

 

="MenuSection">

 

 

 

<asp:ContentPlaceHolder id="_menuPlaceHolder" runat

 

="server">

 

 

 

</asp:ContentPlaceHolder

 

>

 

 

 

</div

 

>

 

 

 

<div class

 

="ContentSection">

 

 

 

<asp:ScriptManager ID="_scriptManager" runat="server"></asp:ScriptManager

 

>

 

 

 

<asp:ContentPlaceHolder id="_mainPlaceHolder" runat="server"></asp:ContentPlaceHolder

 

>

 

 

 

</div

 

>

 

 

 

</form

 

>

</

 

 

body

>

</

 

 

html

>

Parents
No Data
Reply
  • 30
    Verified Answer
    posted

    Oups... sorry for the long snippet I accidentally left in the text.

    MORE IMPORTANTLY... I noticed I had not provided the MasterPage.Master.cs contents. When I went to copy it, I realized I had a Page_Init piece of code to change the master page ID to "_master" (rather than the default "ctl00"). After I removed that, the warnings disappeared.

     

Children
No Data