473,774 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data grid pageing with EnableViewState = False turned on

Hi,

I want EnableViewState = false turned on to optimize the end output page (it
was over 600KB with it on) but when i turn it off, our pageing functionality
no longer works mainly the
PageIndexChange d event no longer fires, how do you handle this with enable
view state as false? thanks!
Nov 18 '05 #1
7 2109
Brian Henry wrote:
Hi,

I want EnableViewState = false turned on to optimize the end output page (it
was over 600KB with it on) but when i turn it off, our pageing functionality
no longer works mainly the
PageIndexChange d event no longer fires, how do you handle this with enable
view state as false? thanks!


http://weblogs.asp.net/datagridgirl/.../19/92716.aspx

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #2
but, as i said the problem is that the page index changed even is never
fired...
"Tampa .NET Koder" <Ta***********@ discussions.mic rosoft.com> wrote in
message news:54******** *************** ***********@mic rosoft.com...
I think you have to rebind the datagrid after each PageIndexChange d event is fired
datagrid1.datab ind()

"Brian Henry" wrote:
Hi,

I want EnableViewState = false turned on to optimize the end output page (it was over 600KB with it on) but when i turn it off, our pageing functionality no longer works mainly the
PageIndexChange d event no longer fires, how do you handle this with enable view state as false? thanks!

Nov 18 '05 #3
hi, i already am data binding at page load and when the even happens, but
stil lthe Page Index Change event never fires when the currentpageinde x is
changed

"Craig Deelsnyder" <cdeelsny@NO_SP AM_4_MEyahoo.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Brian Henry wrote:
Hi,

I want EnableViewState = false turned on to optimize the end output page (it was over 600KB with it on) but when i turn it off, our pageing functionality no longer works mainly the
PageIndexChange d event no longer fires, how do you handle this with enable view state as false? thanks!


http://weblogs.asp.net/datagridgirl/.../19/92716.aspx

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 18 '05 #4
There are a couple other steps to take.

See the subsection "Enduring an Over-sized ViewState" in the following
article:
http://msdn.microsoft.com/library/de...idmistakes.asp

HTH,

--
Scott
http://www.OdeToCode.com

On Wed, 14 Jul 2004 18:29:32 -0400, "Brian Henry"
<br**********@n ewsgroups.nospa m> wrote:
hi, i already am data binding at page load and when the even happens, but
stil lthe Page Index Change event never fires when the currentpageinde x is
changed

"Craig Deelsnyder" <cdeelsny@NO_SP AM_4_MEyahoo.co m> wrote in message
news:%2******* *********@TK2MS FTNGP10.phx.gbl ...
Brian Henry wrote:
> Hi,
>
> I want EnableViewState = false turned on to optimize the end output page(it > was over 600KB with it on) but when i turn it off, our pageingfunctionalit y > no longer works mainly the
> PageIndexChange d event no longer fires, how do you handle this withenable > view state as false? thanks!
>
>


http://weblogs.asp.net/datagridgirl/.../19/92716.aspx

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


Nov 18 '05 #5
Hi Brian,

In addition, are you using custom paging or the buildin paging support?
Have you set the AllowPaging property and AllowCustomPagi ng? If you're
using the buildin paging rather than custom paging, you need to set
AllowPaging as "true" and AllowCustomPagi ng as "false".
Here is a demo page I made using the buildin paging function and with the
EnableViewState as false:
You may have a try on your side to see whether it can provide any clues:
=============== =aspx page=========== =======
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>PagingGr id</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td><FONT face="ËÎÌå"></FONT></td>
</tr>
<tr>
<td>
<asp:DataGrid id="dgPage" runat="server" AutoGenerateCol umns="False"
AllowPaging="Tr ue" PageSize="6"
EnableViewState ="False">
<Columns>
<asp:BoundColum n DataField="inde x"
HeaderText="Ind ex"></asp:BoundColumn >
<asp:BoundColum n DataField="name "
HeaderText="Nam e"></asp:BoundColumn >
<asp:BoundColum n DataField="pric e"
HeaderText="Pri ce"></asp:BoundColumn >
</Columns>
<PagerStyle PageButtonCount ="6" Mode="NumericPa ges"></PagerStyle>
</asp:DataGrid>
</td>
</tr>
</table>
</form>
</body>
</HTML>
==========code behind page class========== ===
public class PagingGrid : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid dgPage;

private void Page_Load(objec t sender, System.EventArg s e)
{
if(!IsPostBack)
{
Session["DATASOURCE "] = GetDataSource() ;
}

Bind_Grid();
}

protected DataTable GetDataSource()
{
DataTable tb = new DataTable();
tb.Columns.Add( "index");
tb.Columns.Add( "name");
tb.Columns.Add( "price",typeof( double));

DataRow dr = null;
bool[] flags = {true,false};
for(int i=1;i<=20;++i)
{
dr = tb.NewRow();
dr["index"] = i.ToString();
dr["name"] = "Name" + i.ToString();
dr["price"] = 3.434 * (i%3 +1);

tb.Rows.Add(dr) ;
}

return tb;
}

protected void Bind_Grid()
{
DataTable tb =(DataTable)Ses sion["DATASOURCE "];
dgPage.DataSour ce = tb;
dgPage.DataBind ();

}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.dgPage.Pag eIndexChanged += new
System.Web.UI.W ebControls.Data GridPageChanged EventHandler(th is.dgPage_PageI n
dexChanged);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void dgPage_PageInde xChanged(object source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
dgPage.CurrentP ageIndex = e.NewPageIndex;
Bind_Grid();
}
}
=============== =============== ===========

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #6
AllowPaging = true
AllowCustomPagi ng = False
EnableViewState = Flase

those are my settings, i havent worked with it yet today, I'm going to try
at this agian here in a minute and see what happenes..
"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:DT******** ******@cpmsftng xa06.phx.gbl...
Hi Brian,

In addition, are you using custom paging or the buildin paging support?
Have you set the AllowPaging property and AllowCustomPagi ng? If you're
using the buildin paging rather than custom paging, you need to set
AllowPaging as "true" and AllowCustomPagi ng as "false".
Here is a demo page I made using the buildin paging function and with the
EnableViewState as false:
You may have a try on your side to see whether it can provide any clues:
=============== =aspx page=========== =======
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>PagingGr id</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td><FONT face="ËÎÌå"></FONT></td>
</tr>
<tr>
<td>
<asp:DataGrid id="dgPage" runat="server" AutoGenerateCol umns="False"
AllowPaging="Tr ue" PageSize="6"
EnableViewState ="False">
<Columns>
<asp:BoundColum n DataField="inde x"
HeaderText="Ind ex"></asp:BoundColumn >
<asp:BoundColum n DataField="name "
HeaderText="Nam e"></asp:BoundColumn >
<asp:BoundColum n DataField="pric e"
HeaderText="Pri ce"></asp:BoundColumn >
</Columns>
<PagerStyle PageButtonCount ="6" Mode="NumericPa ges"></PagerStyle>
</asp:DataGrid>
</td>
</tr>
</table>
</form>
</body>
</HTML>
==========code behind page class========== ===
public class PagingGrid : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid dgPage;

private void Page_Load(objec t sender, System.EventArg s e)
{
if(!IsPostBack)
{
Session["DATASOURCE "] = GetDataSource() ;
}

Bind_Grid();
}

protected DataTable GetDataSource()
{
DataTable tb = new DataTable();
tb.Columns.Add( "index");
tb.Columns.Add( "name");
tb.Columns.Add( "price",typeof( double));

DataRow dr = null;
bool[] flags = {true,false};
for(int i=1;i<=20;++i)
{
dr = tb.NewRow();
dr["index"] = i.ToString();
dr["name"] = "Name" + i.ToString();
dr["price"] = 3.434 * (i%3 +1);

tb.Rows.Add(dr) ;
}

return tb;
}

protected void Bind_Grid()
{
DataTable tb =(DataTable)Ses sion["DATASOURCE "];
dgPage.DataSour ce = tb;
dgPage.DataBind ();

}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.dgPage.Pag eIndexChanged += new
System.Web.UI.W ebControls.Data GridPageChanged EventHandler(th is.dgPage_PageI n dexChanged);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void dgPage_PageInde xChanged(object source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
dgPage.CurrentP ageIndex = e.NewPageIndex;
Bind_Grid();
}
}
=============== =============== ===========

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #7
got it working, thanks!

"Brian Henry" <br**********@n ewsgroups.nospa m> wrote in message
news:u0******** ******@TK2MSFTN GP09.phx.gbl...
AllowPaging = true
AllowCustomPagi ng = False
EnableViewState = Flase

those are my settings, i havent worked with it yet today, I'm going to try
at this agian here in a minute and see what happenes..
"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:DT******** ******@cpmsftng xa06.phx.gbl...
Hi Brian,

In addition, are you using custom paging or the buildin paging support?
Have you set the AllowPaging property and AllowCustomPagi ng? If you're
using the buildin paging rather than custom paging, you need to set
AllowPaging as "true" and AllowCustomPagi ng as "false".
Here is a demo page I made using the buildin paging function and with the EnableViewState as false:
You may have a try on your side to see whether it can provide any clues:
=============== =aspx page=========== =======
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>PagingGr id</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td><FONT face="ËÎÌå"></FONT></td>
</tr>
<tr>
<td>
<asp:DataGrid id="dgPage" runat="server" AutoGenerateCol umns="False"
AllowPaging="Tr ue" PageSize="6"
EnableViewState ="False">
<Columns>
<asp:BoundColum n DataField="inde x"
HeaderText="Ind ex"></asp:BoundColumn >
<asp:BoundColum n DataField="name "
HeaderText="Nam e"></asp:BoundColumn >
<asp:BoundColum n DataField="pric e"
HeaderText="Pri ce"></asp:BoundColumn >
</Columns>
<PagerStyle PageButtonCount ="6" Mode="NumericPa ges"></PagerStyle>
</asp:DataGrid>
</td>
</tr>
</table>
</form>
</body>
</HTML>
==========code behind page class========== ===
public class PagingGrid : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid dgPage;

private void Page_Load(objec t sender, System.EventArg s e)
{
if(!IsPostBack)
{
Session["DATASOURCE "] = GetDataSource() ;
}

Bind_Grid();
}

protected DataTable GetDataSource()
{
DataTable tb = new DataTable();
tb.Columns.Add( "index");
tb.Columns.Add( "name");
tb.Columns.Add( "price",typeof( double));

DataRow dr = null;
bool[] flags = {true,false};
for(int i=1;i<=20;++i)
{
dr = tb.NewRow();
dr["index"] = i.ToString();
dr["name"] = "Name" + i.ToString();
dr["price"] = 3.434 * (i%3 +1);

tb.Rows.Add(dr) ;
}

return tb;
}

protected void Bind_Grid()
{
DataTable tb =(DataTable)Ses sion["DATASOURCE "];
dgPage.DataSour ce = tb;
dgPage.DataBind ();

}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.dgPage.Pag eIndexChanged += new

System.Web.UI.W ebControls.Data GridPageChanged EventHandler(th is.dgPage_PageI n
dexChanged);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void dgPage_PageInde xChanged(object source,
System.Web.UI.W ebControls.Data GridPageChanged EventArgs e)
{
dgPage.CurrentP ageIndex = e.NewPageIndex;
Bind_Grid();
}
}
=============== =============== ===========

Hope helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx


Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1419
by: Jarod | last post by:
hey I tried to make ASP.Net site with a datagrid. On the dg there is a button columnt with command set to select. I put in the code some very simple ItemCommandEvent. In the ... generated code there is this.dgMydata += ... so it should be ok. But it's not. I tried to remove it and recreate everything still nothing. In code there is of course the procedure that should be run. What went wrong ? Jarod
7
3370
by: Brian Henry | last post by:
Hi, I have a data grid that has the following properties EnableViewState = false AllowPaging = true AllowSorting = true AllowCustomPaging = false now, when the page switches I want to get the current page number and display it in a label on the form... but it doesnt seem to return anything but zero no mater which page i am on in CurrentPageIndex property of the
2
2035
by: Brian Henry | last post by:
Hi, I have a data grid that is set up like this Page items displayed = 10 EnableViewState = false (i dont want to send large amounts of data over the internet!) CustomPaging = false AllowPaging = true
2
2312
by: pmud | last post by:
Hi, I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column in data grid is Edit Column. I want to display all columns in Excel except for the Edit column. The following code which I am using allows exporting only from text data from data grid & not from Edit columns which are link buttons. How to leave this column while displaying data from data grid in Excel?
3
2219
by: pmud | last post by:
Hi, I have a web page (asp.net, code:c#). I havean html table with text boxes. Based on the user input , records are displayed in the data grid below it. Now the datagrid has a large no. of columns. & depending on what the user enters, the data grid can grow very large. So to avoid scrolling the whole page, I just want the data grid to be scrollable. For this I used the <div> tags around the data grid, <div...
3
1637
by: Joe | last post by:
Hello all: From what I understand the ItemCommand, UpdateCommand, SortCommand, etc events for the datagrid require that the datagrid's enableVireState property is set to true. Does the page-level enableViewState property affect the control's enableViewState property? I am trying to understand this result: when I have the page's enableViewState turned off and the control's enableViewState turned on, the ItemCommand event never fires...
6
5745
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid to a DataSet. If i include an if statement to prevent the data binding from occuring on a page PostBack in the following way:
1
2064
by: =?Utf-8?B?VmlkZHM=?= | last post by:
Hi All, I am not able to get the sort event when i EnableViewState =false for data grid. Is there any relation betwn those two.Please comment. How can I get through this problem? Thanks in advance. Regards,
6
2738
by: slinky | last post by:
I found the following code to transfer datagrid data to an Excel file. Is this written in C#?... I'm a vb.netter. I'm just not sure where to place the code to experiment on it. Should I place it in the event handler for a form button. Is there other ways to accomplish this? I looked at some on the web and usergroups, but was confused as to the functioning. BTW my datagrid is enclosed in a <div></divfor ease of scrolling if that would...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.