public static void DropDownList_Bind(DropDownList list_name,string DtaTxtField,string DataValueField,String Procedure)
{
OpenConnection();
com = new SqlCommand(Procedure, con);
com.CommandType = CommandType.StoredProcedure;
SqlDataReader dtr = com.ExecuteReader();
list_name.DataSource = dtr;
list_name.DataTextField = DtaTxtField;
list_name.DataValueField = DataValueField;
list_name.DataBind();
dtr.Close();
CloseConnection();
}
public static void OpenConnection()
{
if(con.State==ConnectionState.Closed)
con.Open();
}
public static void CloseConnection()
{
if (con.State == ConnectionState.Open)
con.Close();
}
这是我用于绑定 DropDownList 的业务逻辑代码,它给出了一个 execption已经有一个与此命令关联的打开的 DataReader 必须先关闭。关于。SqlDataReader dtr = com.ExecuteReader();
请给一些建议。提前感谢