|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
radiobutton and datagridhi,
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! 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! 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----- only one row. so> > >hi, >I have a datagrid. i want the user to select a row, and 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! >. >
5th Re-Post with NO RESPONSE FROM MS!
Hyperlink Format DataGrid Export to Excel Can't get a reference to user control in datagrid Problem with Top And Bottom Paging How can I format a telephone # in the datagrid Sorting Datagrid With Hyphen / Dash email validation DataGrid sort when Editing How to put the result of 2 DataReader in a DataList?? |
|||||||||||||||||||||||