I am working in ASP.NET project. And my task is to append the Checkbox text to the TextBox. Checkboxes's text are bound from Database values in CheckBoxList.
protected void prbtn_Click(object sender, EventArgs e)
{
string ConnectionString = "Data Source=.;Initial Catalog=nci;Integrated Security=true";
SqlConnection myConn = new SqlConnection(ConnectionString);
List<string> minire = new List<string>();
string sql = "SELECT distinct PRIMARY_MINI_REGION FROM customers";
myConn.Open();
SqlCommand cmd = new SqlCommand(sql, myConn);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);
minire.Add(dt.Rows[0][0].ToString());
group12.DataSource = dt;
group12.DataTextField = "PRIMARY_MINI_REGION";
group12.DataValueField = "PRIMARY_MINI_REGION";
group12.DataBind();
string[] grpary = prgrp.Text.Split(';');
foreach (var items in grpary)
{
if (items != "")
{
li.Add(items.ToString());
if (li.Contains(items.ToString()))
{
group12.Items.FindByText(items.ToString()).Selected = true;
//group12.Items.FindByText(items.ToString()).Enabled = false;
}
}
}
}
Can any of you please help me how to do it in jquery.Currently i appended text using stringbuilder using C# as like
protected void group_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (ListItem l in group12.Items)
{
if (l.Selected)
{
li.Add(l.Text);
}
}
foreach (var i in li)
{
si.Append(i.ToString() + ";");
}
//if (prgrp.Text == "")
// prgrp.Text = si.ToString();
//else
prgrp.Text = si.ToString();
}
once i select checkbox means it have to append text.and once i unchecked it means,content have to be deleted from textbox