dropdownlist question

Discussion in 'ASP .Net' started by JohnE, Aug 30, 2009.

  1. JohnE

    JohnE Guest

    I have a gridview with paging and a pagesize of 20. Users would like to be
    able to set a higher value. I placed a ddl outside the gridview and put
    numbers into thru the property Items collection. I used 10, 20, 30 ... to
    100. When the user changes the number in the ddl, I need to have the
    pagesize go to that amt. The Items has text and value as the same. I am
    struggling with getting it to work properly and seek assistance with it. So
    if someone can walk me thru this, great. Links to sites are also good.
    John
    JohnE, Aug 30, 2009
    #1
    1. Advertising

  2. JohnE

    JohnE Guest

    Sorry, I forgot to paste in the code I had so far.

    protected void ddlNumberPerPage_SelectedIndexChanged(object sender,
    EventArgs e)
    {
    GridView1.PageSize = 40;
    GridView1.DataSource = bindgrid();
    GridView1.DataBind();
    }

    This works and gives me 40 rows per page. It is what to put in place of 40
    is what is frustrating me.

    Thanks.
    John


    "JohnE" wrote:

    > I have a gridview with paging and a pagesize of 20. Users would like to be
    > able to set a higher value. I placed a ddl outside the gridview and put
    > numbers into thru the property Items collection. I used 10, 20, 30 ... to
    > 100. When the user changes the number in the ddl, I need to have the
    > pagesize go to that amt. The Items has text and value as the same. I am
    > struggling with getting it to work properly and seek assistance with it. So
    > if someone can walk me thru this, great. Links to sites are also good.
    > John
    JohnE, Aug 30, 2009
    #2
    1. Advertising

  3. On Aug 30, 7:20 pm, JohnE <> wrote:
    > Sorry, I forgot to paste in the code I had so far.
    >
    >      protected void ddlNumberPerPage_SelectedIndexChanged(object sender,
    > EventArgs e)
    >     {
    >         GridView1.PageSize = 40;
    >         GridView1.DataSource = bindgrid();
    >         GridView1.DataBind();
    >     }
    >
    > This works and gives me 40 rows per page.  It is what to put in place of 40
    > is what is frustrating me.
    >
    > Thanks.
    > John
    >
    >
    >
    > "JohnE" wrote:
    > > I have a gridview with paging and a pagesize of 20.  Users would like to be
    > > able to set a higher value.  I placed a ddl outside the gridview and put
    > > numbers into thru the property Items collection.  I used 10, 20, 30 .... to
    > > 100.  When the user changes the number in the ddl, I need to have the
    > > pagesize go to that amt.  The Items has text and value as the same.  I am
    > > struggling with getting it to work properly and seek assistance with it..  So
    > > if someone can walk me thru this, great.  Links to sites are also good.
    > > John- Hide quoted text -

    >
    > - Show quoted text -


    Did you tried ddlNumberPerPage.SelectedValue?

    // GridView1.PageSize = 40;
    GridView1.PageSize = ddlNumberPerPage.SelectedValue
    Alexey Smirnov, Aug 30, 2009
    #3
  4. JohnE

    JohnE Guest

    "Alexey Smirnov" wrote:

    > On Aug 30, 7:20 pm, JohnE <> wrote:
    > > Sorry, I forgot to paste in the code I had so far.
    > >
    > > protected void ddlNumberPerPage_SelectedIndexChanged(object sender,
    > > EventArgs e)
    > > {
    > > GridView1.PageSize = 40;
    > > GridView1.DataSource = bindgrid();
    > > GridView1.DataBind();
    > > }
    > >
    > > This works and gives me 40 rows per page. It is what to put in place of 40
    > > is what is frustrating me.
    > >
    > > Thanks.
    > > John
    > >
    > >
    > >
    > > "JohnE" wrote:
    > > > I have a gridview with paging and a pagesize of 20. Users would like to be
    > > > able to set a higher value. I placed a ddl outside the gridview and put
    > > > numbers into thru the property Items collection. I used 10, 20, 30 .... to
    > > > 100. When the user changes the number in the ddl, I need to have the
    > > > pagesize go to that amt. The Items has text and value as the same. I am
    > > > struggling with getting it to work properly and seek assistance with it.. So
    > > > if someone can walk me thru this, great. Links to sites are also good.
    > > > John- Hide quoted text -

    > >
    > > - Show quoted text -

    >
    > Did you tried ddlNumberPerPage.SelectedValue?
    >
    > // GridView1.PageSize = 40;
    > GridView1.PageSize = ddlNumberPerPage.SelectedValue
    >


    Yes. I tried it and the red line appears under all of it. What is says is
    'Cannot implicity converty type string to int'
    JohnE, Aug 30, 2009
    #4
  5. JohnE

    JohnE Guest

    "Mark Rae [MVP]" wrote:

    > "JohnE" <> wrote in message
    > news:...
    >
    > >> Did you tried ddlNumberPerPage.SelectedValue?
    > >>
    > >> // GridView1.PageSize = 40;
    > >> GridView1.PageSize = ddlNumberPerPage.SelectedValue
    > >>

    > >
    > > Yes. I tried it and the red line appears under all of it. What is says
    > > is
    > > 'Cannot implicity converty type string to int'

    >
    > That means exactly what it says - the SelectedValue property of a
    > DropDownList is a string but the PageSize property of a GridView expects an
    > integer...
    >
    > So...
    >
    > GridView1.PageSize = Convert.ToInt32(ddlNumberPerPage.SelectedValue);
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    >
    >


    That did it. I tried several other ways, of which none worked. Got
    frustrated and went and had some ice cream. I might be working at this way
    to much. I need a vacation.
    Thanks again.
    John
    JohnE, Aug 30, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mr2_93
    Replies:
    1
    Views:
    3,581
    mr2_93
    Oct 2, 2005
  2. tshad
    Replies:
    8
    Views:
    2,205
    tshad
    Oct 19, 2005
  3. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,846
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  4. =?Utf-8?B?SnVhbmpv?=

    GridView: Filter DropDownList for another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,282
    =?Utf-8?B?SnVhbmpv?=
    Dec 29, 2005
  5. keithb
    Replies:
    1
    Views:
    11,910
    shauns1
    Nov 1, 2006
Loading...

Share This Page