我需要为@email 和下拉列表中的基础使用会话数据表电子邮件值。
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.DataSource = (DataTable)Session["dt"];
DropDownList1.DataValueField = "base";
DropDownList1.DataTextField = "base";
DropDownList1.DataBind();
}
string str;
protected void Submit_Click(object sender, EventArgs e)
{
if (CheckBox9.Checked == true)
{
str = str + CheckBox9.Text + "x";
}
}
SqlConnection con = new SqlConnection(...);
String sql = "UPDATE INQUIRY2 set Question1 = @str WHERE email = @email AND Base = @base;";
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
cmd.Parameters.AddWithValue("@email", Session.dt.email);
cmd.Parameters.AddWithValue("@str", str);
cmd.Parameters.AddWithValue("@base", DropDownList1.base);
}
}