Problem populating Gridpanel with OBJECT

  1. #1

    Problem populating Gridpanel with OBJECT

    Hi,
    I have found several times the following problem when populating gridpanel.
    My situation is as follows:
    - Two gridpanels in parent-child relationship
    - The gridpanel child is populated by List <object>
    - I do not want gridpanel child is populated when the page loads but only whenever a record father is clicked

    If, as in this case, the gridpanel child is populated by List <object> are forced to bind "empty" in the Page_Load, otherwise each record (which is triggered with each selection of a record on gridpanel father) I would see only blank lines (the correct number of rows but empty!).

    If you populate gridPanel child with objects "typed", it is correct without the need to bind "empty" in the Page_Load.
    Here's an example code:

    protected void Page_Load(object sender, EventArgs e)
    {
    	if (!X.IsAjaxRequest)
    	{
    		this.BindDataUser();
    		this.BindDataRoles(""); //I am forced to enter here otherwise I would see the records "empty"
    	}
    }			
    			
    private void BindDataUser()
    {
        this.StoreUsers.DataSource = new object[]
        {
            new object[] { "1", "Marge"  },
            new object[] { "2", "Homer"  },
            new object[] { "3", "Bart"   }
        };
        this.StoreRoles.DataBind();
    }
    	
    private void BindDataRoles(string userID)
    {
        this.StoreRoles.DataSource = new object[]
        {
            new object[] { "1", "Sport"  },
            new object[] { "2", "Programmer"  },
            new object[] { "3", "Police"   }
        };
        this.StoreRoles.DataBind();
    }

    Instead if I create an object for "Roles", called for example "cRole" defined as:

    public class cRole
    {
        public string ID { get; set; }
        public string Description { get; set; }
        public string Note { get; set; }
     
        public SortedList<string, cRule> Rules;
     
        public cRole()
        {
            Rules = new SortedList<string, cRule>();
        }
    }

    And instantiate the DataSource with:

    private void BindDataRoles(string userID)
    {
        this.StoreRoles.DataSource = new object[]
        {
            new cRole{ID = "AAA1", Description = "BBB1", Note = "CCC1"},
            new cRole{ID = "AAA2", Description = "BBB2", Note = "CCC2"},
            new cRole{ID = "AAA3", Description = "BBB3", Note = "CCC3"}
        };
     
        this.StoreRoles.DataBind();
    }
    I would not be forced to include in the Page_Load bind.
    This is a possible bug?
    Thank you!

    Stefano Lonati
  2. #2
    Hello,

    It's difficult to say something without example to reproduce. However, try to double check model and columns.

Similar Threads

  1. Replies: 6
    Last Post: Oct 22, 2012, 12:51 PM
  2. Replies: 0
    Last Post: Oct 21, 2011, 3:04 AM
  3. Replies: 1
    Last Post: Oct 14, 2011, 9:48 AM
  4. "populating combobox via ajaxevent" problem
    By unaltro2 in forum 1.x Help
    Replies: 0
    Last Post: Nov 16, 2010, 7:43 AM
  5. Replies: 11
    Last Post: Aug 27, 2010, 9:52 PM

Tags for this Thread

Posting Permissions