Home All Groups Group Topic Archive Search About
Author
11 Mar 2005 11:56 AM
Joe Abou Jaoude
hi,
I have a datagrid. i want the user to select a row, and only one row. so
i created a template column where i placed a radiobutton...
Unfortunately this is not working, because the name of the radiobutton
is changing according to the datagrid row, so when i select a
radiobutton this won't deselect another radio button...

any idea how to do something similar
thx

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Author
11 Mar 2005 6:03 PM
David Hearn
Try this. It ought to get you close to what you need.

http://www.dotnetbips.com/displayarticle.aspx?id=147

HTH!

Show quoteHide quote
"Joe Abou Jaoude" <anonym***@devdex.com> wrote in message
news:OeQgvFjJFHA.2560@TK2MSFTNGP09.phx.gbl...
>
>
> hi,
> I have a datagrid. i want the user to select a row, and only one row. so
> i created a template column where i placed a radiobutton...
> Unfortunately this is not working, because the name of the radiobutton
> is changing according to the datagrid row, so when i select a
> radiobutton this won't deselect another radio button...
>
> any idea how to do something similar
> thx
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Author
11 Mar 2005 7:23 PM
Elton Wang
Hi Joe,

I believe it's possible to achieve goal of deselecting
other radio button, when selecting one.

For any server controls in a datagrid, there are two
properties you can use, ID and ClientID. For one server
control of a column in different rows, their IDs will be
same and ClientIDs will be different. So you can try
following code

RadioButton selectedRdBtn = (RadioButton)sender;
RadioButton rdBtn;
string clientID = selectedRdBtn.ClientID;
bool selected  = selectedRdBtn.Checked;
foreach (DataGridItem item in datagrid.Items)
{
    rdBtn = (RadioButton)item.FindControl("rdBtnID");
    if(!rdBtn.ClientID.Equals(clientID)
    {
        rdBtn.Checked = !selected ;
    }
}


HTH

Elton Wang
elton_w***@hotmail.com


>-----Original Message-----
>
>
>hi,
>I have a datagrid. i want the user to select a row, and
only one row. so
Show quoteHide quote
>i created a template column where i placed a
radiobutton...
>Unfortunately this is not working, because the name of
the radiobutton
>is changing according to the datagrid row, so when i
select a
>radiobutton this won't deselect another radio button...
>
>any idea how to do something similar
>thx
>
>*** Sent via Developersdex http://www.developersdex.com
***
>Don't just participate in USENET...get rewarded for it!
>.
>