Dear All,
Design:
<table class="style1">
<tr>
<td align="right">
Name :</td>
<td>
<asp:TextBox ID="TextBox1" runat="server">
</td>
</tr>
<tr>
<td align="right">
Address :</td>
<td>
<asp:TextBox ID="TextBox2" runat="server">
</td>
</tr>
<tr>
<td align="right">
Mobile :</td>
<td>
<asp:TextBox ID="TextBox3" runat="server">
</td>
</tr>
<tr>
<td align="right">
Product Items :</td>
<td>
<asp:CheckBoxList ID="CheckBoxList1" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem>LapTop
<asp:ListItem>Mobile
<asp:ListItem>Bike
</td>
</tr>
<tr>
<td align="right">
</td>
<td>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" />
</td>
</tr>
<tr>
<td align="right">
</td>
<td>
<asp:Label ID="Label1" runat="server" Text="Label">
</td>
</tr>
<tr>
<td align="right">
</td>
<td>
</td>
</tr>
<tr>
<td align="right">
</td>
<td>
</td>
</tr>
<tr>
<td align="right">
</td>
<td>
</td>
</tr>
</table>
Code:
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
con.Open();
string str = "insert into CheckTable values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + CheckBoxList1.SelectedItem.Value + "')";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
con.Close();
Label1.Text = "data inserted sucessfully";
}
Here once fill these like name: kkkk, address: hhhhhh, mobile: 1234567890, product items: laptop, mobile, bike
here after fill store in database table but not storing like:
columns:(name,address,mobile,productItems)= kkkk,hhhhhh,1234567890,laptop,mobile,bike
but storing data in table like:kkkk,hhhhhh,1234567890,laptop
here not store checkbox list all data and i want all please reply me any examples and above code any mistakes please reply me