Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > GridView - Limit user selection to only one row???

Reply
Thread Tools

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

 
 
Randy Smith
Guest
Posts: n/a
 
      04-28-2007
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


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      04-28-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>


 
Reply With Quote
 
 
 
 
Randy Smith
Guest
Posts: n/a
 
      04-28-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>

>



 
Reply With Quote
 
Larry Bud
Guest
Posts: n/a
 
      04-28-2007
On Apr 28, 5:30 pm, "Randy Smith" <(E-Mail Removed)> 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" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > 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" <(E-Mail Removed)> wrote in message
> >news:(E-Mail Removed)...
> >> 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?

 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      04-29-2007
>
> Why use a checkbox, instead of a select button?
>


I agree. RadioButton is also a good option. If you want a free control doing
that, see RowSelectorField at
http://www.wilcob.com/Wilco/Toolbox/WilcoWeb.aspx


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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: How to limit the user only login the system one time at the same t Steven Cheng [MSFT] ASP .Net 1 08-22-2008 10:04 AM
GridView's selection isn't causing other GridView's to load data asexpected Rasika WIJAYARATNE ASP .Net 0 12-14-2007 12:25 AM
How to change data displayed in one GridView depending on selection made in the second one? (ASP.NET 2.0) misiek ASP .Net 7 02-28-2006 09:40 AM
Limit Thunderbird to only one instance running at a time? Z Firefox 2 05-02-2005 09:01 AM
JTable with row selection, but no cell selection Simon Niederberger Java 2 01-07-2005 04:17 PM



Advertisments