473,321 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Customize Paging

Hi All

I have a grid view. I added a drop down list on top of page to select number of records in grid view. Somehow I am unable to do that ...

Here is my code... Could some one please help me out?

Thanks in advance
Expand|Select|Wrap|Line Numbers
  1. <asp:DropDownList ID="ddlSize" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged">
  2.     <asp:ListItem Value="10">10</asp:ListItem>
  3.     <asp:ListItem Value="20">20</asp:ListItem>
  4.     <asp:ListItem Value="30">30</asp:ListItem>
  5. </asp:DropDownList>
  6.  
Expand|Select|Wrap|Line Numbers
  1. protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
  2.         {
  3.             gv.PageSize = ddlPageSize.SelectedValue;
  4.             gv.DataBind();
  5.         }
Dec 21 '08 #1
6 1093
Ramk
61
Try to use the SelectedItem property of the ddl.
Expand|Select|Wrap|Line Numbers
  1. gv.PageSize = ddlPageSize.SelectedItem;
Also, plz wrap your code in the [code] BLOCKS(Click the # symbol available on the extreme right of your editor window), which makes your post easy to read.
Dec 21 '08 #2
Thanks Ram!!!

I changed ddl property to selected item. I am getting a build error like

Cannot implicitly convert System.Web.UI.WebControls.ListItem to 'int'.

I am new to .Net. Could you give more suggestions please...
Dec 21 '08 #3
JamieHowarth0
533 Expert 512MB
Try this:
Expand|Select|Wrap|Line Numbers
  1. gv.PageSize = ddlPageSize.SelectedItem.Value.ToInt()
codegecko
Dec 21 '08 #4
Ramk
61
@codegecko
This will give compilation error.ToInt method doesn't exist in String class.

Use Convert class as follows.
Expand|Select|Wrap|Line Numbers
  1. Convert.ToInt32(ddlSize.SelectedItem.Value)
Dec 22 '08 #5
Frinavale
9,735 Expert Mod 8TB
In addition to Ramk's suggestion, could use the Integer.Parse method:
Expand|Select|Wrap|Line Numbers
  1. gv.PageSize = Integer.Parse(ddlPageSize.SelectedItem.Value);
  2.  
Dec 23 '08 #6
After I changed it like this, was able to bind drop down value to grid view.

Expand|Select|Wrap|Line Numbers
  1.  gvDetails.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
  2.  
Dec 24 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
1
by: Amy Snyder | last post by:
I have a datagrid where I incorporate paging and sorting. My datagrid page mode is set to numeric. Is there a way for me to customize this to display something like this in the page header: ...
2
by: asad | last post by:
Hello friends, i am designing a ASP.NET page where i want to use custom paging bcoz data is too heavy so pls tell me how can i use custom paging in ASP.NET Thanks
0
by: Ray | last post by:
I am trying to add a "Next >" and "<Prev" button to the pager of my datagrid. I have been able to add the hyperlinks to the pager. I am now trying to determine the correct postback script to...
2
by: farhad13841384 | last post by:
Hi , I Hope You fine. I have some problem with this code for paging in asp.net this bottom code work correctly without any error but when I try to place separate code in .VB file then error is...
0
by: anonieko | last post by:
This approach I found very efficient and FAST when compared to the rowcount, or Subquery Approaches. This is before the advent of a ranking function from DB such as ROW_NUMBER() in SQL Server...
2
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
3
by: Ronald S. Cook | last post by:
I was told that if calling lots of records from the database (let's say 100,000), that the GridView's paging feature would automatically "handle" everything. But the 100,000 records are still...
5
by: Donald Adams | last post by:
Hi, I will have both web and win clients and would like to page my data. I could not find out how the datagrid control does it's paging though I did find some sample code that says they do it...
1
osward
by: osward | last post by:
Hi all, I got code over the net for paging mysql table, it provides Prev pages Next link at the bottom of the table. However, I have a pretty large table to display (average over 400+ rows). Even...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.