I have one page and show only one grid. The schema of the grid depends on what action the user selected. When the grid is created I also dynamically set the group.
When the control that was before the postback a RadGrid control, then in the Page_Init event I see that the correct column is used as the groupexpression. In the Page_Load event (which is the next custom code that is running in my app) the groupexpression has been changed to the groupexpressions of the RadGrid that existed before the postback.
My first idea is that it is caused by the viewstate, but I turned off the viewstate of the RadGrid, the MasterTableView and the ColumnViewState of the masterTableView (I am not aware of any other viewstates).
On the first grid or if the control before the postback is another control, everything works fine.
When the control that was before the postback a RadGrid control, then in the Page_Init event I see that the correct column is used as the groupexpression. In the Page_Load event (which is the next custom code that is running in my app) the groupexpression has been changed to the groupexpressions of the RadGrid that existed before the postback.
My first idea is that it is caused by the viewstate, but I turned off the viewstate of the RadGrid, the MasterTableView and the ColumnViewState of the masterTableView (I am not aware of any other viewstates).
On the first grid or if the control before the postback is another control, everything works fine.
6 Answers, 1 is accepted
0
Hello Ewald,
Could you please verify that you create the RadGrid properly like is shown in the following online documentation articles:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html
http://www.telerik.com/help/aspnet-ajax/grid-changing-structure-dynamically.html
Additionally it will be helpful if you could post your aspx page markup with the related code behind file or send us a runnable project which demonstrates the described problem. Thus we will be able to we debug the project and provide you with more to-the-point answer.
Looking forward for your reply.
Kind regards,
Radoslav
the Telerik team
Could you please verify that you create the RadGrid properly like is shown in the following online documentation articles:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html
http://www.telerik.com/help/aspnet-ajax/grid-changing-structure-dynamically.html
Additionally it will be helpful if you could post your aspx page markup with the related code behind file or send us a runnable project which demonstrates the described problem. Thus we will be able to we debug the project and provide you with more to-the-point answer.
Looking forward for your reply.
Kind regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Ewald
Top achievements
Rank 1
answered on 15 Oct 2011, 06:30 PM
Here is a sample app. When I enable the viewstate of the grid, then I see on postback the old data.
When I disable the viewstate I get an error message.
What am I doing wrong?
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>
<
asp:Content
ID
=
"HeaderContent"
runat
=
"server"
ContentPlaceHolderID
=
"HeadContent"
>
</
asp:Content
>
<
asp:Content
ID
=
"BodyContent"
runat
=
"server"
ContentPlaceHolderID
=
"MainContent"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager"
runat
=
"server"
AsyncPostBackTimeout
=
"0"
/>
<
asp:Button
ID
=
"button"
runat
=
"server"
Text
=
"2e grid"
/>
<
asp:PlaceHolder
ID
=
"ph"
runat
=
"server"
/>
</
asp:Content
>
Imports
Telerik.Web.UI
Public
Class
_Default
Inherits
System.Web.UI.Page
Protected
Sub
Page_Init(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Init
ph.Controls.Add(BuildGrid())
End
Sub
Private
Sub
button_Click(sender
As
Object
, e
As
System.EventArgs)
Handles
button.Click
End
Sub
Private
Function
BuildGrid()
As
RadGrid
Dim
groupcolumn =
"isPostback_is_"
+ Page.IsPostBack.ToString()
Dim
ret =
New
RadGrid()
With
{
.EnableViewState =
True
,
.ID =
"myId"
,
.AutoGenerateColumns =
False
}
ret.MasterTableView.EnableColumnsViewState =
False
ret.GroupingEnabled =
True
AddHandler
ret.NeedDataSource,
Sub
(sender
As
Object
, e
As
GridNeedDataSourceEventArgs)
Dim
dt
As
New
DataTable
dt.Columns.Add(
"Id"
,
GetType
(
Integer
))
dt.Columns.Add(groupcolumn,
GetType
(
Integer
))
If
Not
Page.IsPostBack
Then
dt.LoadDataRow(
New
Object
() {1, 1},
True
)
dt.LoadDataRow(
New
Object
() {2, 2},
True
)
Else
dt.LoadDataRow(
New
Object
() {3, 3},
True
)
dt.LoadDataRow(
New
Object
() {4, 4},
True
)
End
If
ret.DataSource = dt
End
Sub
ret.Columns.Add(
New
GridBoundColumn()
With
{.DataField =
"Id"
})
ret.Columns.Add(
New
GridBoundColumn()
With
{.DataField = groupcolumn})
ret.MasterTableView.GroupByExpressions.Add(
New
GridGroupByExpression(
String
.Format(
"{0} GROUP BY {0} ASC"
, groupcolumn)))
Return
ret
End
Function
End
Class
0
Hi Ewald,
Could you please try enabling the ViewState of the RadGrid's columns and let me know if the issue still persists:
End Function
Regards,
Radoslav
the Telerik team
Could you please try enabling the ViewState of the RadGrid's columns and let me know if the issue still persists:
Private
Function
BuildGrid()
As
RadGrid
...
ret.MasterTableView.EnableColumnsViewState =
True
...
End Function
Regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Ewald
Top achievements
Rank 1
answered on 19 Oct 2011, 11:37 AM
The problem still persits when changing that property
0
Hi Ewald,
Could you please try disabling the ViewState of the PlaceHolder control and let me know if the issue still persists:
Looking forward for your reply.
Kind regards,
Radoslav
the Telerik team
Could you please try disabling the ViewState of the PlaceHolder control and let me know if the issue still persists:
<
asp:PlaceHolder
ID
=
"ph"
EnableViewState
=
"false"
runat
=
"server"
/>
Looking forward for your reply.
Kind regards,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Ewald
Top achievements
Rank 1
answered on 26 Oct 2011, 09:34 PM
I don't know what change I did in my code, but it now works.
Thanks for you support anyway.
Thanks for you support anyway.