C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






selecting a radiobutton from gridview


Posted Date: 08 Aug 2008      Total Responses: 2

Posted By: Manoj P J       Member Level: Silver     Points: 1


have an application of online test.I stored all the questions and options in database and displayed on the page.All questions contain 4 options.i have to update the database when a user select one radiobuttn in each row.How can i do it?
Plz help me ,its very urgent..




Responses

Author: ANIL PANDEY    08 Aug 2008Member Level: DiamondRating:     Points: 3
Hello,

hello Manoj,

u can use the Radio button Group, in that a user can select only one option and based on that option u can select a singlr answer and can store in the database..



thanks
Anil


Author: Vidhya    08 Aug 2008Member Level: GoldRating:     Points: 6
hi,

How to manage a radio button in a Gridview? I have tried to select a single radio button out of multiple radio buttons in a Gridview. You can perform this using two ways. The first one is to use server side code. Use checked change property of radio button and find out which radio button has raised the event? and select that radio button; and make others uncheck. You need to set the “AutoPostBack” property of radio button to true to handle “OnCheckedChanged” event.

However, the another way to do is by using javascript. You need to write the following javascript in an aspx page where you are using your Gridview.

<!– Copy Code From Here –>

function CheckOnOff(rdoId,gridName)
{
var rdo = document.getElementById(rdoId);

/* Getting an array of all the “INPUT” controls on the form.*/
var all = document.getElementsByTagName(”input”);
for(i=0;i<all.length;i++)
{
/*Checking if it is a radio button, and also checking if the
id of that radio button is different than “rdoId” */
if(all[i].type==”radio” && all[i].id != rdo.id)
{
var count=all[i].id.indexOf(gridName);
if(count!=-1)
{
all[i].checked=false;
}
}
}
rdo.checked=true;/* Finally making the clicked radio button CHECKED */
}

<!– End Copying Code –>

You have to set the following properties of a radio button in a Gridview, to allow this script run properly.

<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,’myGrid’);”></asp:RadioButton> </ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


Happy programming!

Note:
Kindly rate this content if it helps!



Post Reply
You must Sign In to post a response.
Next : Croping Images in Asp.Net
Previous : search option
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use