这个是用dropdownlist绑定数据,在通过在gridview中读取drop。。的值,希望大家帮帮我。 20
protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){stringsql=System.Conf...
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sql = System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
SqlConnection conn = new SqlConnection(sql);
string str = "select coursename from teacher,courseinfo where teacher.courseno=courseinfo.courseno and userid ='" + Session["userid"] + "'";
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(str, conn);
DataSet ds = new DataSet();
sda.Fill(ds);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "coursename";
DropDownList1.DataBind();
conn.Close();
}
}
这是绑定dropdownlist那部分代码,数据绑定没问题,但是因为这里使用了!Ispostback,因此在按老方法写gridview的编辑操作时,老出问题,大家帮忙看看,出出主意,谢谢啦。 展开
{
if (!IsPostBack)
{
string sql = System.Configuration.ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
SqlConnection conn = new SqlConnection(sql);
string str = "select coursename from teacher,courseinfo where teacher.courseno=courseinfo.courseno and userid ='" + Session["userid"] + "'";
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(str, conn);
DataSet ds = new DataSet();
sda.Fill(ds);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "coursename";
DropDownList1.DataBind();
conn.Close();
}
}
这是绑定dropdownlist那部分代码,数据绑定没问题,但是因为这里使用了!Ispostback,因此在按老方法写gridview的编辑操作时,老出问题,大家帮忙看看,出出主意,谢谢啦。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询