前台:
Code
<tr>
<td height="25" bgcolor="#D5F1F4" align="right" >CSS样式:</td>
<td bgcolor="#FFFFFF">
<asp:DropDownList ID="ddlClassCss" runat="server">
</asp:DropDownList>
</td>
</tr>
CS:
Code
/// <summary>
/// 初始化
/// </summary>
public void Init()
{
DataSet ds = new DataSet();
ds = DALClassCSS.GetClassCSSDataSet();
ddlClassCss.DataSource = ds.Tables[0].DefaultView;
ddlClassCss.DataTextField = "CSSName";
ddlClassCss.DataValueField = "CSS";
ddlClassCss.DataBind();
ddlClassCss.Items.Insert(0,new ListItem("--请选择--",""));
}
OR:
Code
/// <summary>
/// 初始化
/// </summary>
public void Init()
{
string strTemp = "";
DataSet ds = new DataSet();
ds = DALClassCSS.GetClassCSSDataSet();
ddlClassCss.Items.Add(new ListItem("--请选择--", ""));
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{ //此处具体看你的dsUserName.Tables[0]结构写了
strTemp = ds.Tables[0].Rows[i][0];
ListItem li = new ListItem(strTemp, strTemp);
ddlClassCss.Items.Add(li);
}
ddlClassCss.Items.FindByText("选择名字").Selected = true;
}