Dynamic Troubles

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Halaszj

    #1

    Dynamic Troubles

    Does anyone know how I can bind these dropdowns to a
    reader?

    HtmlTable tbl = new HtmlTable();
    HtmlTableRow tr = new HtmlTableRow();
    HtmlTableCell td1 = new HtmlTableCell() ;
    HtmlTableCell td2 = new HtmlTableCell() ;
    HtmlTableCell td3 = new HtmlTableCell() ;
    HtmlTableCell td4 = new HtmlTableCell() ;

    // Create a textbox and a dropdown to hold the values
    td2.Controls.Ad d(new TextBox());
    td4.Controls.Ad d(new DropDownList()) ;

    // Name the objects
    td2.ID = "txtCassett e" +(i+1);
    td4.ID = "ddlDenominatio n" +(i+1);

    // Put the text in the empty cells
    td1.InnerHtml = "Cassette #" +(i+1);
    td3.InnerHtml = "Denominati on";

    // Add the cells to the row
    tr.Cells.Add(td 1);
    tr.Cells.Add(td 2);
    tr.Cells.Add(td 3);
    tr.Cells.Add(td 4);

    // Add the row to the table
    tbl.Rows.Add(tr );

    // Add the table to the placeholder
    Container.Contr ols.Add(tbl);

    --This is the part that is broke that I need help with--
    //ddlDenomination (i).DataSource = cmd.ExecuteRead er();
    //ddlDenomination (i).DataTextFie ld = "name";
    //ddlDenomination (i).DataValueFi eld = "denominationid ";
    //ddlDenomination (i).DataBind();

    //Loop
    i++;
Working...