COMBOBOX C#数据库
来源:百度知道 编辑:UC知道 时间:2024/06/23 07:49:01
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
DataBind();
string strSql="select distinct p_storeid from p_sales where p_date='081230'";
comboBox1.DataSource=this.SqlGetDataSet(strSql,true).Tables[0];
}
private void DataBind()
{
string strSql="select distinct p_storeid from p_sales where p_date='081230'";
comboBox1.DataSource=this.SqlGetDataSet(strSql,true).Tables[0];
}
private void DataBind()
{
string strSql="select distinct p_storeid from p_sales where p_date='081230'";
comboBox1.DataSource=this.SqlGetDataSet(strSql,true).Tables[0];
comboBox1.DataBind();//这绑定下
}
comboBox1_SelectedIndexChanged这个事件里你调用自身的绑定?
设置好DataSource,后要DataBind();下
前台
<asp:DropDownList id="combobox1" runat="server" AutoPostBack="True" onselectedindexchanged="ddlrefectory_SelectedIndexChanged"/>
要加AutoPostBack="True"
后台要写绑定列
this.combobox1.DataTextField="列名";
this.combobox1.DataValueField="列名";
this.combobox1.DataBind();
不明白在问我吧
//要绑定列
this.combobox1.DataTextField="列名";
this.combobox1.DataValueField="列名";
//然后再Bind()下
this.combobox1.DataBind();
1,2楼在忽悠人
首先检查一下你的SQL语句真的查询到数据了吗
private void DataBind()
{
string str