周易风水算命:对不起,还是.NET基本问题

来源:百度文库 编辑:中科新闻网 时间:2024/05/06 13:01:09
为什么我的DropDownList控件绑定了数据,选择完以后他总是执行DropDownList默认的那一行呢,我是这么写的:

string i = DropDownList1.SelectedItem.Text.ToString();
SqlConnection con = new SqlConnection("server=.;uid=sa;pwd=zhenyi;database=lala;");
con.Open();
SqlCommand com = new SqlCommand("select * from Customers where 检测日期 ='"+i.ToString() + "'",con);
SqlDataReader dr = com.ExecuteReader();
this.DataGrid1.DataSource=dr;
this.DataGrid1.DataBind();
DataGrid1.Visible = true;

if(!this.isPostBack)
{
//你把这些代码放在这里面就可以了
}

这里没有问题,可能是数据绑定时出了问题。