By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 2,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

Setting GridView PageSize at runtime

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a

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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.