User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,234 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,772 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3599 | Replies: 2 | Solved
Reply
Join Date: Apr 2007
Posts: 262
Reputation: greeny_1984 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz in Training

checkbox as a itemtemplate in a datalist

  #1  
Nov 12th, 2007
hii every one,
i have an application containing data list.
datalist contains radio button as item template.i want only one radio button to be checked ie when the user clicks on one checkbox the other checkboxes should be unchecked.i have used groupname ,but no use .can any one give the solution to this problem.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: checkbox as a itemtemplate in a datalist

  #2  
Nov 12th, 2007
well, you can use checkboxlist but it doesn't work like radio buttons do. The user will be able to select multiple ones if you choose checkboxes instead of radio buttons. But if you decide to do checkboxes, use javascript to uncheck the other boxes in your group.
<script type="text/javascript">
function selectChkBox(field,checkit)
{
  for (i = 0; i < field.length; i++) {
	field[i].checked = false;
  }
  checkit.checked = true;
}
</script>

then call it with an OnClick event like below:

<label><input type="checkbox" id="chkSelection" name="checkbox3" value="3" onclick="javascript:selectChkBox(document.formname.chkSelection,this.name)" />Checkbox 3</label>
I haven't tested it, but it should work. What it does is set all the checkboxes to unchecked, then checks the corresponding checkbox found by its name. Make sure that all your checkboxes are one ID (that are affected anyway), and then have each one a different name.
Reply With Quote  
Join Date: Apr 2007
Posts: 262
Reputation: greeny_1984 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz in Training

Re: checkbox as a itemtemplate in a datalist

  #3  
Nov 13th, 2007
hii,
i have found the solution to this problem.The problem and solution to this issue is very well addressed in the following two articles.
hope this helps others,

http://aspnet.4guysfromrolla.com/articles/122602-1.aspx

http://www.codeproject.com/aspnet/Ho...sp?msg=1188105
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 5:10 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC