Add control to datagrid

L

Luiz Vianna

Folks,

I'm trying to programaly add a RadioButton to my datagrid using this code bellow.

When I run the aspx page the RadioButton apears, but when I click on it, it did not fire
the sub "myRadioButton_Click" as designed bellow...

Any ideas?

Thanks,

Luiz

------

Dim _item As DataGridItem
Dim myRadioButton As New RadioButton

_item = MyDataGrid.Items(1)

myRadioButton.EnableViewState = True
myRadioButton.ID = "RadioButton1"
myRadioButton.GroupName = "RadioGroup1"
myRadioButton.Text = "Alternatives"

AddHandler myRadioButton.CheckedChanged, AddressOf myRadioButton_Click

_item.Cells(2).Controls.Add(myRadioButton)
 
K

Ken Cox [Microsoft MVP]

Hi Luiz,

Don't forget to set autopostback=true

myRadioButton.AutoPostBack = True

Was that it?

Ken
Microsoft MVP [ASP.NET]


Folks,

I'm trying to programaly add a RadioButton to my datagrid using this code
bellow.

When I run the aspx page the RadioButton apears, but when I click on it, it
did not fire
the sub "myRadioButton_Click" as designed bellow...

Any ideas?

Thanks,

Luiz

------

Dim _item As DataGridItem
Dim myRadioButton As New RadioButton

_item = MyDataGrid.Items(1)

myRadioButton.EnableViewState = True
myRadioButton.ID = "RadioButton1"
myRadioButton.GroupName = "RadioGroup1"
myRadioButton.Text = "Alternatives"

AddHandler myRadioButton.CheckedChanged, AddressOf myRadioButton_Click

_item.Cells(2).Controls.Add(myRadioButton)
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top