给你参考一下: 
protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!IsPostBack) 
        { 
            SqlConnection con = new SqlConnection("server=;database=province;uid=sa;pwd=sa;"); 
            con.Open(); 
            SqlCommand cmd = new SqlCommand("select * from province", con); 
            SqlDataReader sdr = cmd.ExecuteReader(); 
            DropDownList1.DataSource = sdr; 
            DropDownList1.DataTextField = "proname"; 
            DropDownList1.DataValueField = "proid"; 
            DropDownList1.DataBind(); 
            con.Close(); 
            sdr.Close(); 
        } 
        
        
    } 
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
      
            SqlConnection con = new SqlConnection("server=;database=province;uid=sa;pwd=sa;"); 
            con.Open(); 
            SqlCommand cmd2 = new SqlCommand("select * from city where pro> 

 

 

前台:
<td class="td_page">新闻类型:</td>
<td><asp:DropDownList ID="dropNewType" runat="server"></asp:DropDownList></td>
 
后台:
DataTable dt = CDB.FillTable("select TypeId, TypeContent from [newsTypeTable]");
dropNewType.DataSource = dt;
dropNewType.DataTextField = "typeContent";
dropNewType.DataValueField = "TypeId";
dropNewType.DataBind();

相关文章:

  • 2022-12-23
  • 2021-05-16
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2021-09-24
  • 2021-05-13
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案