Last post Nov 02, 2015 02:02 AM by Candice Zhou
Oct 31, 2015 04:17 PM|akpaga22|LINK
I need to have check boxes beside a text and need to append the text to them in the following way
say chekbox [p ] checkbox [h] customer
chekbox [p ] checkbox [h] non-customer
chekbox [p ] checkbox [h] manager
if checkbox p is checked p-customer should be inserted and if if p and h both are checked it should be inserted as p-customer,h-customer.
Same pattern should be followed for non-customer and manager.
One the data is inserted in the Sql server db, i would like to bind the checkboxes by reading data from the db for update purpose.
In this scenario, whats the best way to handle this? Please guide . Thank you
Nov 02, 2015 02:02 AM|Candice Zhou|LINK
Based on your requirement, I think you want to save CheckBox text to Database. I created the sample for you, code shown below:
On .aspx page:
<asp:CheckBox ID="customerp" runat="server" Text="p-customer" />
<asp:Button Text="Submit" runat="server" OnClick="Submit" />
On .aspx.cs page:
protected void Submit(object sender, EventArgs e)
if (customerp.Checked == true)
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
using (SqlCommand cmd = new SqlCommand("INSERT INTO Customers(customer) VALUES(@customer)"))
cmd.Connection = con;