dynamic checkbox

Discussion in 'ASP .Net' started by James Wong, Dec 13, 2006.

  1. James Wong

    James Wong Guest

    Dear Sir,

    I want to create some dynamic checkbox controls into the table.
    How can I get these controls after the form is submitted.
    -----------------------------------------------------
    e.g.
    For i = 1 to 9
    trwRow = New TableRow
    chkCheckBox = New CheckBox
    chkCheckBox.ID = "c" + CStr(i)
    tclCell = New TableCell
    tclCell.Controls.Add(chkCheckBox)
    trwRow.Cells.Add(tclCell)
    Next
    -----------------------------------------------------
    Thanks!

    James
    James Wong, Dec 13, 2006
    #1
    1. Advertising

  2. Hi,

    How about this code:

    for (int i = 0; i < 9; i++)
    {
    TableRow tr = new TableRow();
    TableCell tc = new TableCell();
    CheckBox chkCheckBox = new CheckBox

    chkCheckBox .Attributes.Add("runat", "Server");
    chkCheckBox .EnableViewState = true;
    chkCheckBox .ID = "chkCheckBox " + i;

    tc.Controls.Add(chkCheckBox );
    tr.Cells.Add(tc);
    table.Rows.Add(tr);
    }

    Thanks and Regards,
    manish bafna

    "James Wong" wrote:

    > Dear Sir,
    >
    > I want to create some dynamic checkbox controls into the table.
    > How can I get these controls after the form is submitted.
    > -----------------------------------------------------
    > e.g.
    > For i = 1 to 9
    > trwRow = New TableRow
    > chkCheckBox = New CheckBox
    > chkCheckBox.ID = "c" + CStr(i)
    > tclCell = New TableCell
    > tclCell.Controls.Add(chkCheckBox)
    > trwRow.Cells.Add(tclCell)
    > Next
    > -----------------------------------------------------
    > Thanks!
    >
    > James
    >
    >
    >
    >
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=, Dec 13, 2006
    #2
    1. Advertising

  3. James,

    You have to recreate dynamically created controls on every postback.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "James Wong" <> wrote in message
    news:...
    > Dear Sir,
    >
    > I want to create some dynamic checkbox controls into the table.
    > How can I get these controls after the form is submitted.
    > -----------------------------------------------------
    > e.g.
    > For i = 1 to 9
    > trwRow = New TableRow
    > chkCheckBox = New CheckBox
    > chkCheckBox.ID = "c" + CStr(i)
    > tclCell = New TableCell
    > tclCell.Controls.Add(chkCheckBox)
    > trwRow.Cells.Add(tclCell)
    > Next
    > -----------------------------------------------------
    > Thanks!
    >
    > James
    >
    >
    >
    Eliyahu Goldin, Dec 13, 2006
    #3
  4. James Wong

    James Wong Guest

    Dear Eliyahu Goldin,

    Thanks a lot.

    James


    "Eliyahu Goldin" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > James,
    >
    > You have to recreate dynamically created controls on every postback.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    >
    > "James Wong" <> wrote in message
    > news:...
    >> Dear Sir,
    >>
    >> I want to create some dynamic checkbox controls into the table.
    >> How can I get these controls after the form is submitted.
    >> -----------------------------------------------------
    >> e.g.
    >> For i = 1 to 9
    >> trwRow = New TableRow
    >> chkCheckBox = New CheckBox
    >> chkCheckBox.ID = "c" + CStr(i)
    >> tclCell = New TableCell
    >> tclCell.Controls.Add(chkCheckBox)
    >> trwRow.Cells.Add(tclCell)
    >> Next
    >> -----------------------------------------------------
    >> Thanks!
    >>
    >> James
    >>
    >>
    >>

    >
    >
    James Wong, Dec 13, 2006
    #4
    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. tshad
    Replies:
    0
    Views:
    491
    tshad
    Apr 15, 2005
  2. Vikram

    disable checkbox list checkbox

    Vikram, Jan 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,362
    ThunderMusic
    Jan 25, 2006
  3. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    787
    David Wier
    Oct 6, 2006
  4. pizzy
    Replies:
    0
    Views:
    154
    pizzy
    Mar 23, 2005
  5. pizzy
    Replies:
    5
    Views:
    372
    pizzy
    Apr 12, 2005
Loading...

Share This Page