We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

ViewStateMode

Thread ID:

Created:

Updated:

Platform:

Replies:

119171 May 18,2015 09:18 AM May 22,2015 12:45 PM ASP.NET Web Forms 6
loading
Tags: Grid
Egi Žaberl
Asked On May 18, 2015 09:18 AM

I am trying to enable ASP.NET ViewState maintenance for grid control but with no luck. No matter what i do, grid looses it's data after postback - on button click. I do not want to rebind grid after each postback.
Please help me how to maintain Grid ViewState.

ASPX

<asp:Button ID="cmd" runat="server" Text="test" OnClick="cmd_Click" />
<asp:Label ID="lbl" runat="server" />

<ej:Grid ID="gvList" runat="server" OnServerRecordClick="gvList_ServerRecordClick" SkinID="List" ViewStateMode="Enabled" AllowPaging="true">
<Columns>
<ej:Column HeaderText="Id" Field="id" IsPrimaryKey="True" TextAlign="Center" Width="50"></ej:Column>
<ej:Column HeaderText="Name" Field="name"></ej:Column>
<ej:Column HeaderText="Description" Field="description"></ej:Column>
</Columns>
</ej:Grid>

Code Behind

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
BindList();
}

private void BindList()
{
gvList.DataSource = DAL.GetData();
gvList.DataBind();
}

protected void cmd_Click(object sender, EventArgs e)
{
lbl.Text = "grid viewstate test";
}

Regards, Egi


Balaji Marimuthu [Syncfusion]
Replied On May 19, 2015 08:12 AM

Hi Egi,

Thanks for using Syncfusion Products.

We have analyzed your reported issue and we suggest you to use the EnablePersistence property in the Grid. Please find the below code snippet.

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">

<asp:Button ID="cmd" runat="server" Text="test" OnClick="cmd_Click" />

<asp:Label ID="lbl" runat="server" />


<ej:Grid ID="Grid" runat="server" AllowPaging="true" EnablePersistence="True">


. . . . . .


</ej:Grid>
</asp:Content>


If we set the EnablePersistence property as true, it will maintain the grid model state and no need to rebind the dataSource for each postback. Please refer the below code snippet.


protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

BindList();

}




Please refer the sample for further details:
Sample119171.zip

Please let us know if you have any queries.

Regards,
Balaji Marimuthu

Egi Žaberl
Replied On May 19, 2015 10:09 AM

Hi Balaji,

thank you for your answer and attached sample. When i run this sample on my dev machine grid is not rebinded on button click grid says "No records to display". My dev machine is Win 7 Pro, VS 2013 Community + integrated IIS and different browsers (latest Chrome, IE 8, 11, latest FF).

What to do now?

This is source of postback page after button click:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>
Home Page
</title><link rel='nofollow' href="favicon.ico" rel="shortcut icon" type="image/x-icon" /><link rel='nofollow' href="Content/ej/ej.widgets.core.min.css" rel="stylesheet" /><link rel='nofollow' href="Content/ej/flat-lime/ej.theme.min.css" rel="stylesheet" />
<script src="Scripts/jquery-1.10.2.min.js"></script>
<script src="Scripts/jsviews.min.js"></script>
<script src="Scripts/jsrender.min.js"></script>
<script src="Scripts/jquery.easing-1.3.min.js"></script>
<script src="Scripts/jquery.globalize.min.js"></script>
<script src="Scripts/ej.web.all.min.js"></script>
<script src="Scripts/ej.webform.min.js"></script>
<script type="text/javascript">
ej.Grid.prototype._ignoreOnPersist.push("allowGrouping");
</script>
<meta name="viewport" content="width=device-width" /></head>
<body>
<form method="post" action="Default" onsubmit="javascript:return WebForm_OnSubmit();" id="ctl01">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="COoM5jpqAYYYgPFI7ifjyiWW06yMnNB5pybaW9+yx2ZuVRs337PmnJb0MbFi7WJl4BE8mbMN81dyVLAIOrJxP82jRTH2j5krkJ7jns7c2TWZAZM1f5J8uH18NQYd39kHU7gcrpSNsj4o079tTIvxauAdWowGrOo4GRJJ3hILhxK/dAqeRNYsBO7ZU0EanbPc3NdgCeyjyEx1OgybjD5R8wI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iYwFlAqz+v0ghrZ4HSWTthafHARuhH9yPaLyY/mfUDnEv0zpkvgQnr058ZTOGr+NYkniqCexf8yoyq3Is+EeHhnReNabtu+QkRLfzHejqvs/DIZCyJTJaiv7A1m4WogWOo3veSUXVf2vYwNKfevJ7AOZ2hr7PuqF0Z9aHoAx4S6xtS5EqLr/j1kp4XLvgpZjJRcdBbr4XOY8=" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['ctl01'];
if (!theForm) {
theForm = document.ctl01;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<script src="/WebResource.axd?d=pynGkmcFUV13He1Qd6_TZNPQHxEHNrAEszBnR0vjF1Whbh-qaMTLxu66SSlpvdReehkzmpoW3P_HTccJNF73LA2&amp;t=635634486620000000" type="text/javascript"></script>
<script src="Scripts/WebForms/MsAjax/MicrosoftAjax.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>
<script src="Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
typeof EJ_ClientSideOnPostBack == 'function' && EJ_ClientSideOnPostBack();
return true;
}
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ctl00$ctl09', 'ctl01', [], [], [], 90, 'ctl00');
//]]>
</script>
<input type="submit" name="ctl00$MainContent$cmd" value="test" id="MainContent_cmd" />
<span id="MainContent_lbl">grid viewstate test</span>
<div id="MainContent_Grid"></div><span id="MainContent_Grid"></span>
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="CA0B0334" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="sxQwiUv8DOEE3zc73MYwGEByK043JIOWoXVOmYBqxT2hx8c/hkMHTKIJ00RSoGmVDLi8NbBf7hFuesNO8nz9DD423zDvK3UZ7Qfb8wtJqFIHUhJR2/gwz7b04tdLQJht" />
</div>
<script type="text/javascript">
//<![CDATA[
$("#MainContent_Grid").ejGrid({allowPaging:true,query:{"queries":[],"_key":"","_fKey":"","_expands":[],"_sortedColumns":[],"_groupedColumns":[],"_subQuery":null,"_isChild":false,"_params":[]},exportToExcelAction:"ExportToExcel",exportToWordAction:"ExportToWord",exportToPdfAction:"ExportToPdf",cssClass:"",enablePersistence:true,columns:[{field:"EmployeeID",headerText:"Employee ID",textAlign:"right",isPrimaryKey:true,width:75,type:"number"},{field:"FirstName",headerText:"First Name",width:80,type:"string"},{field:"LastName",headerText:"Last Name",width:75,type:"string"},{field:"Number",headerText:"Age",textAlign:"right",width:75,type:"number"},{field:"Country",headerText:"Country",width:110,type:"string"}],pageSettings:{currentPage:0,locale:"en-US"},filterSettings:{filterType:"Excel",filterBarMode:"onenter"},scrollSettings:{width:"auto"},toolbarSettings:{showToolbar:true,toolbarItems:["add","edit","delete","update","cancel"]},editSettings:{allowEditing:true,allowAdding:true,allowDeleting:true,formPosition:"topRight"},"clientId":"MainContent_Grid","uniqueId":"ctl00$MainContent$Grid"});
//]]>
</script>
</form>
<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
{"appName":"Chrome","requestId":"9db61fa6e76c4851a5106778f5bdea20"}
</script>
<script type="text/javascript" src="http://localhost:65025/75fc2db5f17f48aea4c02d97f4d770a3/browserLink" async="async"></script>
<!-- End Browser Link -->
</body>
</html>

Regards, Egi

Balaji Marimuthu [Syncfusion]
Replied On May 20, 2015 09:20 AM

Hi Egi,

We are sorry about the inconvenience caused.

We have missed to include the code, which is necessary for the requirement. So please include the below code snippet in your application.


<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">

<asp:Button ID="cmd" runat="server" Text="test" OnClick="cmd_Click" />

<asp:Label ID="lbl" runat="server" />


<ej:Grid ID="Grid" runat="server" AllowPaging="true" EnablePersistence="True">


. . . . . .


</ej:Grid>


<script type="text/javascript">

var index = $.inArray("dataSource", ej.Grid.prototype._ignoreOnPersist);

ej.Grid.prototype._ignoreOnPersist.splice(index, 1);

</script>
</asp:Content>


For your convenience, we have attached the sample in the following link:
Sample: Sample.zip

Please let us know if you have any queries.

Regards,
Balaji Marimuthu

Egi Žaberl
Replied On May 21, 2015 03:00 AM

Thank you! Now, grid is maintaining it's state on a button click.

Maybe it would be nice to include this sample in your on-line documentation. And also for other controls, not just grid.

Regards, Egi

Egi Žaberl
Replied On May 21, 2015 03:41 AM

After additional testing i have found out that grid is now maintaining it's state regardless changing data source. I have changed GetRecords method so it returns less data ( .. for (int i = 1; i < 5; i++) ..), added BindList() action to cmd_click, but on the page/grid there is no effect after click on a button. Grid still shows data and all it's selections from previous data source so grid is not rebinded. 
This persistence is not what ViewState supposed to be. Is there any other option that i have missed?

protected void Page_Load(object sender, EventArgs e)
{
   if (!IsPostBack)
      BindList();
}

private void BindList()
{
    Grid.DataSource = emp.GetRecords();
    Grid.DataBind();
}

protected void cmd_Click(object sender, EventArgs e)
{
    lbl.Text = "grid viewstate test";
    BindList();
}

Balaji Marimuthu [Syncfusion]
Replied On May 22, 2015 12:45 PM

Hi Egi,

Query:# This persistence is not what ViewState supposed to be. Is there any other option that i have missed?

We have considered this requirement “Need to support for ViewState to maintain dataSource in Grid” as a usability issue and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents


Also, we suggest you to use the below workaround solution to achieve your requirement. Could you please find the below code snippet:

EmployeeDetails emp = new EmployeeDetails();


protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

BindList();

}


private void BindList()

{

Grid.DataSource = emp.GetRecords();

Grid.DataBind();

}

private void BindList1()

{

Grid.DataSource = emp.GetRecords1();

Grid.DataBind();

}

protected void cmd_Click(object sender, EventArgs e)

{

lbl.Text = "grid viewstate test";

Grid.EnablePersistence = false;

BindList1();
}



If we disabled the enablepersistence property by setting as false, we can rebind the dataSource to Grid. So could you please try using the above method and for your convenience we have attached the sample:
Sample: Sample-119171.zip


Query:#2 Maybe it would be nice to include this sample in your on-line documentation. And also for other controls, not just grid.


Thanks for your suggestions. Please find the below response.


1. Mobile controls
We have logged an UG improvement task to update document for enablePersistence features of our Mobile Controls.
This will be completed and refreshed in online by our upcoming Essential Studio 2015 Volume 2 release which is expected to be roll out on June 26th, 2015.
2. Maps and tree map control
We have logged an UG task for enablePersistence features in Maps and tree map control. It will be available in our upcoming Volume 2 release.
3. Schedule
We have considered your requirement and have created the “ UG documentation task for the ViewState details ” with High priority and we will update it in our online location as soon as possible.
4. Chart
We have already created the task for documentation of viewstatemode. It will be available in our upcoming Volume 2 release.
5. Grid Control
We have logged the Documentation task for ViewState property to maintain datasource in Grid.


Please let us know if you have any queries.


Regards,

Balaji Marimuthu


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;