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
633
Read-Only Behaviors NOT WORKING when Binding to Custom Collection
posted

I can't get built in behaviors to work when binding to my custom collection, it works perfectly when using a SQLDataSource. Is there something my custom collection needs to implement to get this functionality working correctly?? I've tried Dictionary, BindingList, and List, none of which have worked... Code is below:

 

ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %>

 

<%@ Register Assembly="Infragistics4.Web.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"

    Namespace="Infragistics.Web.UI.GridControls" TagPrefix="ig" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <asp:ScriptManager ID="ScriptManager1" runat="server">

        </asp:ScriptManager>

        <ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="100%">

            <Behaviors>

                <ig:ColumnMoving DragMarkupCssClass="">

                </ig:ColumnMoving>

                <ig:ColumnResizing>

                </ig:ColumnResizing>

                <ig:Filtering>

                </ig:Filtering>

                <ig:Paging PageSize="10">

                </ig:Paging>

                <ig:RowSelectors>

                </ig:RowSelectors>

                <ig:Selection CellClickAction="Row" CellSelectType="None" 

                    RowSelectType="Single">

                </ig:Selection>

                <ig:Sorting>

                </ig:Sorting>

            </Behaviors>

        </ig:WebDataGrid>

    </div>

    </form>

</body>

</html>

Code-Behind
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication4
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        private MyObjectCollection _MyObjectCollection = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                _MyObjectCollection = new MyObjectCollection();
                _MyObjectCollection.Add(new MyObject("Scott", "Scott is cool - 99", 1));
                _MyObjectCollection.Add(new MyObject("Fred", "Scott is cool - 88", 2));
                _MyObjectCollection.Add(new MyObject("Jim", "Scott is cool - 2345", 3));
                _MyObjectCollection.Add(new MyObject("Marvin", "Scott is cool- 2345", 4));
                _MyObjectCollection.Add(new MyObject("Jason", "Scott is cool- 34561", 5));
                _MyObjectCollection.Add(new MyObject("Candace", "Scott is cool- 7890", 6));
                _MyObjectCollection.Add(new MyObject("Lisa", "Scott is cool- 34576", 7));
                _MyObjectCollection.Add(new MyObject("Alice", "Scott is cool- sdfg34", 8));
                _MyObjectCollection.Add(new MyObject("Katy", "Scott is cool - 45yert", 9));
                _MyObjectCollection.Add(new MyObject("Carson", "Scott is cool -34563rg", 10));
                _MyObjectCollection.Add(new MyObject("Kevin", "Scott is cool-467rtbh", 11));
                _MyObjectCollection.Add(new MyObject("Kayleigh", "Scott is cool-5y64trh", 12));
                _MyObjectCollection.Add(new MyObject("Sam", "Scott is cool-35y35rg", 13));
                _MyObjectCollection.Add(new MyObject("Brandi", "Scott is cool-45ytg", 14));
                WebDataGrid1.DataSource = _MyObjectCollection;
                WebDataGrid1.DataBind();
            }
        }
    }
    public class MyObjectCollection : List<MyObject>
    {
    }
    public class MyObject
    {
        public string Name { get; set; }
        public string Description { get; set; }
        public int MyValue { get; set; }
        public MyObject(string name, string desc, int val)
        {
            Name = name;
            Description = desc;
            MyValue = val;
        }
    }
}