Hi,
I am having difficulty with the RadGrid control (inside a user control) not databinding items by the PreRender event. The documentation says the lifecycle is as follows:
I am binding to a ObjectDataSource control:
<telerik:RadGrid ID="rgProgrammes" runat="server" AutoGenerateColumns="False"
DataSourceID="ods_Programmes" GridLines="None" Skin="Office2007">
<MasterTableView DataKeyNames="pim_ID, CombinedCode" DataSourceID="ods_Programmes">
(i also bind to a GridView to check if that works)
Then in code behind I do a simple check for if it has databound :
protected void Page_PreRender(object sender, EventArgs e)
{
int test = rgProgrammes.Items.Count; //result = 0
int test2 = GridView1.Rows.Count; //result = 3
}
Have I misunderstood something about the lifecycle of the RadGrid? When I insert breakpoints in my code, the Page_PreRender
event gets called before the RadGrid_DataBound event. This is giving me difficulty using a RadGrid in a user control
.
Any help would be appreciated.
Tom
I am having difficulty with the RadGrid control (inside a user control) not databinding items by the PreRender event. The documentation says the lifecycle is as follows:
First page load: | |
Page.Load | |
Grid_Instance.NeedDataSource | |
Foreach Item in Grid_Instance: | |
ItemCreated | |
ItemDataBound | |
Page.PreRender |
I am binding to a ObjectDataSource control:
<telerik:RadGrid ID="rgProgrammes" runat="server" AutoGenerateColumns="False"
DataSourceID="ods_Programmes" GridLines="None" Skin="Office2007">
<MasterTableView DataKeyNames="pim_ID, CombinedCode" DataSourceID="ods_Programmes">
(i also bind to a GridView to check if that works)
Then in code behind I do a simple check for if it has databound :
protected void Page_PreRender(object sender, EventArgs e)
{
int test = rgProgrammes.Items.Count; //result = 0
int test2 = GridView1.Rows.Count; //result = 3
}
Have I misunderstood something about the lifecycle of the RadGrid? When I insert breakpoints in my code, the Page_PreRender
event gets called before the RadGrid_DataBound event. This is giving me difficulty using a RadGrid in a user control
.
Any help would be appreciated.
Tom