Add control to datagrid

Discussion in 'ASP .Net Web Controls' started by Luiz Vianna, Jan 9, 2005.

  1. Luiz Vianna

    Luiz Vianna Guest

    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)
    Luiz Vianna, Jan 9, 2005
    #1
    1. Advertising

  2. Hi Luiz,

    Don't forget to set autopostback=true

    myRadioButton.AutoPostBack = True

    Was that it?

    Ken
    Microsoft MVP [ASP.NET]


    "Luiz Vianna" <> wrote in message
    news:...
    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)
    Ken Cox [Microsoft MVP], Jan 10, 2005
    #2
    1. Advertising

  3. Luiz Vianna

    Luiz Vianna Guest

    OK Ken,

    that's what it was missing....

    Thanks

    Luiz

    "Ken Cox [Microsoft MVP]" <> escreveu na mensagem
    news:...
    > Hi Luiz,
    >
    > Don't forget to set autopostback=true
    >
    > myRadioButton.AutoPostBack = True
    >
    > Was that it?
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    >
    >
    > "Luiz Vianna" <> wrote in message
    > news:...
    > 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)
    >
    Luiz Vianna, Jan 10, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    0
    Views:
    525
  2. Grey

    add button control in datagrid

    Grey, Jan 16, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,268
    Alvin Bruney
    Jan 17, 2004
  3. Scott Allen
    Replies:
    0
    Views:
    2,058
    Scott Allen
    Aug 29, 2004
  4. =?Utf-8?B?Q2hyaXMgRmluaw==?=

    How to dynamically add control to datagrid item template

    =?Utf-8?B?Q2hyaXMgRmluaw==?=, Aug 20, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    572
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=
    Aug 21, 2007
  5. Chad Scharf
    Replies:
    3
    Views:
    860
    Chad Scharf
    Oct 18, 2007
Loading...

Share This Page