aspx文件
<asp:DropDownList ID="ddlDType" runat="server" DataValueField="infoID" DataTextField="bmname"> </asp:DropDownList>
cs文件
public void getDataLeiC() { string sql = "select * from xqybumeng_info where infotype='2'"; SqlConnection conn = BaseClass.DBCon(); SqlDataAdapter sda = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); sda.Fill(ds); this.ddlDType.DataSource = ds.Tables[0].DefaultView; this.ddlDType.DataBind(); this.ddlDType.Items.Insert(0, new ListItem("请选择", "0")); }
//判断是否选择
if (ddlDType.SelectedItem.Value != "0")
{}