Click here to Skip to main content
Licence 
First Posted 12 Apr 2004
Views 120,717
Bookmarked 32 times

Adding and Using RadioButton to DataGrid in ASP.NET

By | 9 May 2004 | Article
Adding and using RadioButton to DataGrid in ASP.NET.

Introduction

How can we add RadioButtons to a DataGrid in ASP.NET? And how can we use server side scripts when we click a RadioButton on the grid? This is the (smart :) solution.

Using the code

Use this script to create RadioButtons. When a RadioButton is clicked, OnCheckedChanged event will be fired. Write a server-side code to catch this event.

<asp:DataGrid id="dgOrnek" runat="server" 
 AutoGenerateColumns="False">
  
   <Columns>
     <asp:TemplateColumn>
       <ItemTemplate>
         <asp:RadioButton AutoPostBack=True 
             OnCheckedChanged="DetayGoster" 
             id="rbsira" Text='deneme' runat="server"/>
       <ItemTemplate>
     <TemplateColumn>
   <Columns>
string sRbText="";
 public void DetayGoster(object sender,EventArgs e) {
     RadioButton rb = new RadioButton();
     rb = (RadioButton) sender;
     sRbText = rb.ClientID;
 
     foreach (DataGridItem i in dgOrnek.Items) 
     {
         rb    = (RadioButton) i.FindControl ("rbsira");
         rb.Checked = false;
         if (sRbText==rb.ClientID)
         {
             rb.Checked = true;
             txtSiraNo.Text = rb.Text.Trim(); 
  // if you want to get a property of the selected id
         }
     }
  }

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Mustafa Dikgitmez

Web Developer

Turkey Turkey

Member

I am from Turkey and working on MRP/ERP Projects.


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow to group radio buttons / inputs inside ASP.NET ListView and GridView PinmemberEJocys1:23 10 Oct '08  
Generalhaj Pinmemberhaja me23:44 28 Sep '07  
Generalagain. Pinmemberibizq20:30 9 Oct '06  
Generalradiobutton to datagrid (Using javascrip) Pinmemberibizq20:28 9 Oct '06  
Questionhow about Pinmember{07E21C0D-C1B0-4236-BA41-6D1C73429BE4}15:02 6 Aug '06  
GeneralAnother approach PinmemberJVMFX9:57 3 Feb '06  
GeneralRe: Another approach Pinmemberpdangelo6:04 13 Feb '06  
GeneralRe: Another approach PinmemberJVMFX7:00 13 Feb '06  
GeneralRe: Another approach Pinmemberpdangelo19:28 13 Feb '06  
GeneralConvert into VB.net! PinmemberDo Hong Nhung22:05 3 Feb '05  
GeneralRe: Convert into VB.net! PinsusshabaneroQueen5:52 27 Feb '05  
GeneralRe: Convert into VB.net! PinsussSpecificity7:46 22 Jun '05  
Generaloops PinsussSpecificity7:49 22 Jun '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120528.1 | Last Updated 10 May 2004
Article Copyright 2004 by Mustafa Dikgitmez
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid