How to reuse a dropdownlist each row of a table instead of rebuilding it.

Posted by Praesagus on Stack Overflow See other posts from Stack Overflow or by Praesagus
Published on 2010-04-30T21:49:11Z Indexed on 2010/04/30 21:57 UTC
Read the original article Hit count: 303

Filed under:
|
|

I have a table the uses the same dropdown list in each row. I thought that I could just create one dropdown list and then reuse it in each new row, but the table only ends up with one row unless I create "new" dropdownlist. Am I approaching this all wrong?

Thanks

private void UserRoles()
{
    Table table = MakeTable();
    Ewo.sqlDataStore.Administrator sql = new Ewo.sqlDataStore.Administrator();
    DataSet dataset =sql.SiteUserRoleList();
    DropDownList sel = RoleList(dataset.Tables[0]);
    if(tools.validDataSet(dataset))
    {
        if (dataset.Tables.Count > 1)//existing roles are #2, show the roles the user is part of
        {
            foreach (DataRow dRow in dataset.Tables[1].Rows)
            {
                table.Rows.Add(CreateRoleRow(Convert.ToString(dRow["SitePageGroupName"]), sel));//add a row with data
            }
        }
        table.Rows.Add(CreateRoleRow(sel));//add a blank row on the bottom
    }
    AdminSiteUerRoles.Controls.Add(table);//add it all to the page
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET