Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

s
More...

Resources » TypeScript » Scripting Languages » Javascript

How select one radio button from multiple radio button in gridview


Posted Date:     Category: Javascript    
Author: Member Level: Gold    Points: 10


If you want to placed a radio button in gridview as selecting one out of more then one radio button, so use my resources. In this resources user can select single radio button option out of multiple radio button from gridview control using by javascript. No need for define group name in radio button.



 


Create a test.aspx page.

On test.aspx page



Paste below javascript on .aspx page.


function CheckOnOff(rdoId,grid)
{
var rdo = document.getElementById(rdoId);
var all = document.getElementsByTagName("input");
for(i=0;i {
if(all[i].type=="radio" && all[i].id != rdo.id)
{
var count=all[i].id.indexOf(grid);
if(count!=-1)
{
all[i].checked=false;
}
}
}
rdo.checked=true;/* Finally making the clicked radio button CHECKED */
}


Now set a gridview on body section of aspx page and placed a radio button control in TemplateField.
set the following properties of a radio button in a Gridview, to allow this script run properly. as following:

<asp:GridView ID="myGrid" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:RadioButton id="rdobutton" runat="server" OnClick="javascript:CheckOnOff(this.id,'grid_FreeGifts');"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


Now User can select only one radio button option from multiple option.


Thanks and Regards
Varun Bansal





Did you like this resource? Share it with your friends and show your love!


Responses to "How select one radio button from multiple radio button in gridview"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Disabling the right click on web page using javascript
    Previous Resource: How to pass Query String value from java script
    Return to Resources
    Post New Resource
    Category: Javascript


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Select single radio buton using javascript  .  Radiobutton using javascript  .  
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.