GridView - Limit user selection to only one row???

Discussion in 'ASP .Net' started by Randy Smith, Apr 28, 2007.

  1. Randy Smith

    Randy Smith Guest

    Hi,
    I would like to limit my user selection to only one row in the GridView at a
    time. Is there any way to set this?

    TIA, Randy
    Randy Smith, Apr 28, 2007
    #1
    1. Advertising

  2. Randy Smith

    Teemu Keiski Guest

    Isn't it that by default if you rely on using "Select" command and
    GridView's SelectedIndex property. E.g have Buttons etc which have
    CommandName="Select" defined, which changes grid's selected row. If you get
    the selected row via SelectedIndex/SelectedRow properties, I don't see you'd
    have a problem. E.g if you use GridView's own row-selection mechanism

    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net


    "Randy Smith" <> wrote in message
    news:...
    > Hi,
    > I would like to limit my user selection to only one row in the GridView at
    > a time. Is there any way to set this?
    >
    > TIA, Randy
    >
    Teemu Keiski, Apr 28, 2007
    #2
    1. Advertising

  3. Randy Smith

    Randy Smith Guest

    Hi,
    I was given code to check to see if any rows are selected, but I want to
    limit my user to selecting only one row. Here is the code I was given:

    foreach (GridViewRow row in GridView1.Rows)
    {
    CheckBox chk1 = (CheckBox) row.FindControl("chk1");
    if (chk1.Checked == true)
    {
    //code goes here
    }
    }

    So, the above listed code makes it obvious that more than one row can be
    selected at any given time.
    TIA, Randy




    "Teemu Keiski" <> wrote in message
    news:...
    > Isn't it that by default if you rely on using "Select" command and
    > GridView's SelectedIndex property. E.g have Buttons etc which have
    > CommandName="Select" defined, which changes grid's selected row. If you
    > get the selected row via SelectedIndex/SelectedRow properties, I don't see
    > you'd have a problem. E.g if you use GridView's own row-selection
    > mechanism
    >
    > --
    > Teemu Keiski
    > AspInsider, ASP.NET MVP
    > http://blogs.aspadvice.com/joteke
    > http://teemukeiski.net
    >
    >
    > "Randy Smith" <> wrote in message
    > news:...
    >> Hi,
    >> I would like to limit my user selection to only one row in the GridView
    >> at a time. Is there any way to set this?
    >>
    >> TIA, Randy
    >>

    >
    Randy Smith, Apr 28, 2007
    #3
  4. Randy Smith

    Larry Bud Guest

    On Apr 28, 5:30 pm, "Randy Smith" <> wrote:
    > Hi,
    > I was given code to check to see if any rows are selected, but I want to
    > limit my user to selecting only one row. Here is the code I was given:
    >
    > foreach (GridViewRow row in GridView1.Rows)
    > {
    > CheckBox chk1 = (CheckBox) row.FindControl("chk1");
    > if (chk1.Checked == true)
    > {
    > //code goes here
    > }
    > }
    >
    > So, the above listed code makes it obvious that more than one row can be
    > selected at any given time.
    > TIA, Randy
    >
    > "Teemu Keiski" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Isn't it that by default if you rely on using "Select" command and
    > > GridView's SelectedIndex property. E.g have Buttons etc which have
    > > CommandName="Select" defined, which changes grid's selected row. If you
    > > get the selected row via SelectedIndex/SelectedRow properties, I don't see
    > > you'd have a problem. E.g if you use GridView's own row-selection
    > > mechanism

    >
    > > --
    > > Teemu Keiski
    > > AspInsider, ASP.NET MVP
    > >http://blogs.aspadvice.com/joteke
    > >http://teemukeiski.net

    >
    > > "Randy Smith" <> wrote in message
    > >news:...
    > >> Hi,
    > >> I would like to limit my user selection to only one row in the GridView
    > >> at a time. Is there any way to set this?

    >
    > >> TIA, Randy- Hide quoted text -

    >
    > - Show quoted text -


    Why use a checkbox, instead of a select button?
    Larry Bud, Apr 28, 2007
    #4
  5. Randy Smith

    Teemu Keiski Guest

    Teemu Keiski, Apr 29, 2007
    #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. Luis Esteban Valencia

    My addnew row button is only adding one row?

    Luis Esteban Valencia, Mar 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    809
    Luis Esteban Valencia
    Mar 23, 2005
  2. Simon Niederberger
    Replies:
    2
    Views:
    16,452
    Christian Kaufhold
    Jan 7, 2005
  3. H5N1
    Replies:
    0
    Views:
    2,700
  4. Steven Cheng [MSFT]
    Replies:
    1
    Views:
    350
    Frederik Van Lierde
    Aug 22, 2008
  5. Selected Row Only GridView Row Visible?

    , Oct 17, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    280
Loading...

Share This Page