ダイアログボックスのチェックボックスがオンになっていて、ボタンをクリックしてもデータがデータベースに保存されない場合は 'N'のみ保存されますがチェックボックスにチェックが入れられ、この問題を解決するために。チェックボックスをオンにすると、データベースに「Y」を保存します。 HTMLはチェックボックスの値がデータベースに挿入されていない
: - これは、私はが私の側にあなたのコードをデバッグチェックボックスが
<form id="form1" runat="server">
<div id="dialog">
<label>First</label>
<asp:CheckBox ID="CheckBox1" runat="server" />
<label>Second</label>
<asp:CheckBox ID="CheckBox2" runat="server" />
<label>Third</label>
<asp:CheckBox ID="CheckBox3" runat="server" />
</div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button2_Click" />
</form>
Jquery:-here is the jquery script.dialogbox with checkbox
<script type="text/javascript">
$(document).ready(function() {
$("#dialog").dialog({
buttons: {
Ok: function() {
$("[id*=Button1]").click();
},
Close: function() {
$(this).dialog('close');
}
}
});
});
</script>
Code Behind:- c# code behind file inserting data in database using ado and sql
protected void Button2_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(Page.GetType(), "key", "alert('Button Clicked')", true);
string First = CheckBox1.Checked ? "Y" : "N";
string Second = CheckBox2.Checked ? "Y" : "N";
string Third = CheckBox3.Checked ? "Y" : "N";
string cs = ConfigurationManager.ConnectionStrings["DUM01ConnectionString"].ConnectionString;
using (SqlConnection scon = new SqlConnection(cs))
{
using (SqlCommand cmd = new SqlCommand("insert into Checkbox (First,Second,Third) values(@First,@Second,@Third)"))
{
cmd.Connection = scon;
cmd.Parameters.AddWithValue("@First", First);
cmd.Parameters.AddWithValue("@Second", Second);
cmd.Parameters.AddWithValue("@Third", Third);
scon.Open();
cmd.ExecuteNonQuery();
scon.Close();
}
}
}
it saves only 'N' to database if checkbox is checked then also it saves 'N' to database how to solve
助け、あなたがWebフォーム上のチェックボックス – BNN