473,513 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting GridView PageSize at runtime

Hello,

Using VWD 2005 here and I want to set the GridView PageSize at runtime.
This URL has an example of what I exactly want to do...
http://msdn2.microsoft.com/en-US/lib....pagesize.aspx

Public Overridable Property PageSize As Integer

Dim instance As GridView
Dim value As Integer

value = instance.PageSize

instance.PageSize = value

Where I'm stuck is where does this code go? In what method to I put
this code into? I tried using GridView1.Load and it didn't work.

Any assitance is greatly appreciated... thanks!

May 16 '06 #1
4 3731
You can put this code in Page_Load of your page.

"Adam Sandler" <co****@excite.com> wrote in message
news:11*********************@j55g2000cwa.googlegro ups.com...
Hello,

Using VWD 2005 here and I want to set the GridView PageSize at runtime.
This URL has an example of what I exactly want to do...
http://msdn2.microsoft.com/en-US/lib....pagesize.aspx

Public Overridable Property PageSize As Integer

Dim instance As GridView
Dim value As Integer

value = instance.PageSize

instance.PageSize = value

Where I'm stuck is where does this code go? In what method to I put
this code into? I tried using GridView1.Load and it didn't work.

Any assitance is greatly appreciated... thanks!

May 16 '06 #2

Winista wrote:
You can put this code in Page_Load of your page.


Actually, I cannot... Public Overridable Property PageSize() As Integer
is a declaration... I get an error if I put a declaration inside an
event handler body.

VWD 2005 will create this stub for me:

Public Overridable Property PageSize() As Integer
Get

End Get
Set(ByVal value As Integer)

End Set
End Property

But that's where I get really confused... how does the code know which
PageSize I'm talking about? There could be more than 1 Gridview on a
page. Using e. and Me. doesn't help me out with scope issues.

May 16 '06 #3
grdMyGrid.PageSize = 10

"Adam Sandler" <co****@excite.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...

Winista wrote:
You can put this code in Page_Load of your page.


Actually, I cannot... Public Overridable Property PageSize() As Integer
is a declaration... I get an error if I put a declaration inside an
event handler body.

VWD 2005 will create this stub for me:

Public Overridable Property PageSize() As Integer
Get

End Get
Set(ByVal value As Integer)

End Set
End Property

But that's where I get really confused... how does the code know which
PageSize I'm talking about? There could be more than 1 Gridview on a
page. Using e. and Me. doesn't help me out with scope issues.

May 16 '06 #4
All... thanks for your help. I'm not sure if any code smells exist
here but this works:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim iPageSize As Integer
Dim myGridView As GridView
Dim ta As New DataSet1TableAdapters.T_ORDERSTableAdapter

myGridView = Me.GridView1
iPageSize = ta.GetData.Select.Length

myGridView.PageSize = iPageSize
End Sub

May 16 '06 #5

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

Similar topics

7
5459
by: Ken | last post by:
Hi All - I have a filtered GridView. This GridView has a check box in the first column. This check box is used to identify specific rows for delete operations. On the button click event I loop through the filtered GridView to identify the selected rows and assemble some XML to be sent to a stored proc. The problem I have is that when...
3
1591
by: John Daly | last post by:
I am using a Gridview to display a phone directory, with paging on. I have a link button that a user clicks to add a new record, which reloads the page, sets the visble property to false on the gridview and shows the form view in insert mode. Upon saving, the process is reversed. All is well and dandy, however I want to jump to the page that...
4
15282
by: Chuck | last post by:
I'm setting the column with for a gridview (25+- columns) and have paging turned on. When the gridview is first displayed, the column widths are all set to the default. But after paging to another page, the widths are set as they should be. Going back to page one, the widths are still correct. Not a clue what's going on here!
8
8517
by: AG | last post by:
ASP.NET 2.0, VS 2005 I have a gridview with paging enabled, bound to an objectdatasource. Both were dropped on to the page and configured via the wizards. Basically working as expected. The gridview's databind method is apparently called when the page is loaded as I have no code calling the databind method. How can I keep the gridview...
3
1921
by: Nathan Sokalski | last post by:
I have a GridView control with three columns, all BoundField columns. They all have a HeaderText and DataField property set, and the third one has a DataFormatString property as well. When I run my code, the GridView displays two sets of columns. The first set looks exactly as I would expect. The second set, which should not be there anyway,...
1
1828
nitindel
by: nitindel | last post by:
Hi All, Please tell me any good site for Gridview control.(not for datagrid). I am facing error in fetching the values of the Bound columns in the gridview: lease tell me how should i fetch the value..of a bound column..?? Below is the code.:
0
1223
by: Jeff | last post by:
hi there ;) asp.net 2.0 I'm having problem with paging in GridView, I'm using custom paging. The ObjectDataSource reads in the rows needed for displaying each page as each page is selected. So that the entire resultset isn't read, but instead just enough to display the pages. The problem now is that the GridView is only displaying the...
8
30013
by: hiranmaie | last post by:
Hi, I am having 3 textboxes and 1 gridview. I want to pass (reflect) the values from textboxes to gridview. I am not using the database here. I want to save the data directly from textboxes into the gridview. The asp code for the gridview goes like this:
3
3079
by: anjali5 | last post by:
Hello Everyone, I want to display an image in my gridview. The only thing is my datatabse table is returning true if there is an image and false if there is no image and I am binding my gridview with dataset. This dataset contains a colun called hasAttachments as true or false. Is it possible to display image in the image field? This...
0
7270
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...
1
7128
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...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4759
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3255
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...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
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
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.