Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 11th, 2007, 03:19 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Bangalore, Karnataka, India.
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default radio button in grid view

hello to all
i used item template in grid view and used radio button in it. but i am able to select more than one radio button in grid view i need user must be able to select only one. please guide how to do?

rtegards,
munish

thanks......
__________________
thanks......
  #2 (permalink)  
Old May 12th, 2007, 05:39 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Bangalore, Karnataka, India.
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

please i need it badly any body have solution

Munish

thanks......
  #3 (permalink)  
Old May 23rd, 2007, 01:50 AM
Authorized User
 
Join Date: May 2007
Location: Frankfurt, Germany, Germany.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to DarkForce
Default

how did u manage to put radio buttons in the grid view?
got source code example?



So long
  #4 (permalink)  
Old August 3rd, 2007, 07:47 PM
Registered User
 
Join Date: Aug 2007
Location: Hyderabad, Andhra Pradesh, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to lakkim_Ravi
Default

munish

place HTML radio button insted of asp radio button in the

Item template of the gridview just like below

<asp:TemplateField>
   <ItemTemplate>
    <input name="myRadio" type="radio" value='<%# Eval("Value") %>' />
   </ItemTemplate>
</asp:TemplateField>

and use below code to retrieve the selected radiobutton's binded value

Response.Write(Request.Form["myRadio"]);
----------------------------------------
hope this will help you




  #5 (permalink)  
Old August 4th, 2007, 02:24 AM
Friend of Wrox
 
Join Date: Feb 2006
Location: noida, UP, India.
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

User is able to check more than one radiobutton because each row in gridview is independent of other. If you want user to only select one radiobutton, you can use javascript.
  #6 (permalink)  
Old August 4th, 2007, 01:44 PM
Friend of Wrox
 
Join Date: Aug 2006
Location: Bangalore, Karnataka, India.
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

well you started thread again.
can you provide javascript code for that.


thanks......
  #7 (permalink)  
Old August 6th, 2007, 04:41 AM
Friend of Wrox
 
Join Date: Feb 2006
Location: noida, UP, India.
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

Edit ItemTemplate as follow:

<asp:TemplateField>
   <ItemTemplate>
    <input name="myRadio" onclick="return function1();" type="radio" value='<%# Eval("Value") %>' />
   </ItemTemplate>
</asp:TemplateField>

Add a javascript function as follow:

function1()
{
var elm=document.form1.elements;
for(i=0;i<elm.length;i++)
   {
     if(elm[i].type=="radio")
     {
       if(elm[i].checked==true)
       {
       alert('you can select only one radio button');
       return false;
       }
     }
  }
}
  #8 (permalink)  
Old August 8th, 2007, 12:47 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Bangalore, Karnataka, India.
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks a lot. Man

thanks......
  #9 (permalink)  
Old August 8th, 2007, 04:47 AM
Friend of Wrox
 
Join Date: Feb 2006
Location: noida, UP, India.
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

You welcome.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Grid View Drop Down List, view all jskinner123 ASP.NET 2.0 Basics 0 November 25th, 2007 06:25 PM
grid view MunishBhatia ASP.NET 2.0 Professional 2 June 5th, 2007 12:15 AM
Group name for radio buttons in Grid view nitinp ASP.NET 2.0 Professional 0 February 27th, 2007 07:15 AM
Data Grid with Radio Button g_vamsi_krish ASP.NET 1.0 and 1.1 Basics 1 March 24th, 2006 03:09 PM
Button acts depending on radio button values janise Access 4 March 10th, 2004 12:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.