Results 1 to 6 of 6

Thread: combo box values

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    combo box values

    hello i have these codes in a page:

    1st loop:
    Code:
     for (int i = 1; i <= recordCount5; i++)
            {
                if (dr.HasRows)
                {
                    dr.Read();
                    ////1st row - Add Text to cell and add Cell to Row
                    htRow = new HtmlTableRow();
                    htCell = new HtmlTableCell();
                    htCell.Align = "left";
                    htCell.InnerText = "***" + dr["QUESTION"].ToString();                htRow.Cells.Add(htCell);
                    tbl.Rows.Add(htRow);
                    htCell = new HtmlTableCell();
                    DropDownList cbo5 = new DropDownList();
                    cbo5.SelectedIndexChanged += new EventHandler(cbo5_SelectedIndexChanged);
                    cbo5.ID = "cbo5" + i.ToString();
                    cbo5.Items.Add("");
                    cbo5.Items.Add("1");
                    cbo5.Items.Add("2");
                    cbo5.Items.Add("3");
                    cbo5.Items.Add("4");
                    cbo5.Items.Add("5");
                    htCell.Controls.Add(cbo5);
                    htRow.Cells.Add(htCell);
                }
            }
    2nd loop:
    Code:
     for (int i = 1; i <= recordCount6; i++)
            {
                if (dr.HasRows)
                {
                    dr.Read();
                    ////1st row - Add Text to cell and add Cell to Row
                    htRow = new HtmlTableRow();
                    htCell = new HtmlTableCell();
                    htCell.Align = "left";
                    htCell.InnerText = "   " + dr["QUESTION"].ToString();                htRow.Cells.Add(htCell);
                    tbl.Rows.Add(htRow);
                    htCell = new HtmlTableCell();
                    DropDownList cbo6 = new DropDownList();
                    cbo5.SelectedIndexChanged += new EventHandler(cbo5_SelectedIndexChanged);
                    cbo6.ID = "cbo6" + i.ToString();
                    cbo6.Items.Add("");
                    cbo6.Items.Add("1");
                    cbo6.Items.Add("2");
                    cbo6.Items.Add("3");
                    cbo6.Items.Add("4");
                    cbo6.Items.Add("5");
                    htCell.Controls.Add(cbo6);
                    htRow.Cells.Add(htCell);
                }
            }
    how would i get all the values in the loop?
    tnx
    *****************
    VB6,PHP,VS 2005

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: combo box values

    What values?

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: combo box values

    Hey,

    Like Mend, I am really not sure that I understand the question. Can you provide some more context as to what exactly you are trying to achieve?

    Gary

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: combo box values

    ok. in the example above imagine that there are 10 comboboxes then
    how can i get all values in the 10 comboboxes take note that the comboboxes are dynamic they are created in run time.

    tnx
    *****************
    VB6,PHP,VS 2005

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    /root/usr/local/bin
    Posts
    476

    Re: combo box values

    this was solved by doing below.


    Code:
    protected void Button1_Click(object sender, EventArgs e)
    {
    for (int i = 1; i <= 10; i++)
            {
                lblError.Text = lblError.Text  + (DropDownList)this.FindControl("cbo5" + i)).Text;
            }
    }
    *****************
    VB6,PHP,VS 2005

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: combo box values

    Hey,

    I am still not sure exactly what you are trying to achieve, but it sounds like you have got what you wanted.

    Remember to mark your thread resolved.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width