Add radio button into datagrid

G

Guest

Hi,

I appreciate if someone provide sample codes of how to add radio buttons
into a datagrid.
 
C

cAm

Li said:
Hi,

I appreciate if someone provide sample codes of how to add radio buttons
into a datagrid.

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>
........


Dim sRbText as String = ""
Public Sub DetayGoster(sender as object, e as eventargs)
Dim rb as New RadioButton
rb= (RadioButton) sender
sRbText = rb.ClientId

Dim item

For each item in dgOrnek.Items
rb = (RadioButton) i.FindControl("rbsira")
rb.Checked = false
if sRbText=rb.ClientID then
rb.Checked = true
txtSiraNo.Text = rb.Text.Trim()
// if you want to get a property of the selected id
end if
Next
End Sub


In VB.NET you have to find out how to translate
rb= (RadioButton) sender (taken from c#)

i think you should try as
rb = sender

Best of luck ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top