0

@email とドロップダウンリストのベースにセッション dataTable の 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);
}

}

4

1 に答える 1