Nov 21, 2012, 2:42 PM
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:
Instead if I create an object for "Roles", called for example "cRole" defined as:
And instantiate the DataSource with:
This is a possible bug?
Thank you!
Stefano Lonati
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