You can done this in following ways:
webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="popddl.aspx.cs" Inherits="Ajax_sample.popddl" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1"
runat="server"></ajaxToolkit:ToolkitScriptManager>
<asp:UpdatePanel ID="updatepanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"
style="top: 152px; left: 354px; position: absolute; height: 22px; width: 128px"></asp:TextBox><asp:Button ID ="Button1" runat ="server" Text ="Save" />
<ajaxToolkit:PopupControlExtender ID="TextBox1_PopupControlExtender" runat="server" DynamicServicePath=""
Enabled="True" ExtenderControlID="" TargetControlID="TextBox1" PopupControlID="Panel1"
OffsetY="22"></ajaxToolkit:PopupControlExtender>
<asp:Panel ID="Panel1" runat="server" Height="116px" Width="145px" BorderStyle="Solid"
BorderWidth="2px" Direction="LeftToRight" ScrollBars="Auto" BackColor="#CCCCCC"
Style="display: none">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="SqlDataSource1" AutoPostBack="True" DataTextField ="Name" OnSelectedIndexChanged = "CheckBoxList1_SelectedIndexChanged" >
</asp:CheckBoxList>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:scriptConnectionString %>"
SelectCommand="SELECT [Name] FROM [Table1]"></asp:SqlDataSource>
</div>
<p>
<asp:Button ID ="b1" runat ="server" Text ="Save" onclick="b1_Click"
style="top: 151px; left: 514px; position: absolute; height: 26px; width: 42px" />
</p>
</form>
</body>
</html>
webform1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace Ajax_sample
{
public partial class popddl : System.Web.UI.Page
{
SqlConnection sqlcon = new SqlConnection("User ID=sa;Password=Mobius@123;Data Source=MOB-PERLZ-WS192;Initial Catalog=script");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void b1_Click(object sender, EventArgs e)
{
sqlcon.Open();
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
SqlCommand sqlcmd = new SqlCommand("insert into Checked_Items values('" + CheckBoxList1.Items[i].Text + "')", sqlcon);
sqlcmd.ExecuteNonQuery();
}
else
{
SqlCommand sqlcmd1 = new SqlCommand("insert into UnChecked_Items values('" + CheckBoxList1.Items[i].Text + "')", sqlcon);
sqlcmd1.ExecuteNonQuery();
}
}
sqlcon.Close();
Response.Write("Saved Successfully");
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
string name = "";
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
name += CheckBoxList1.Items[i].Text + ",";
}
}
TextBox1.Text = name;
}
}
}