TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
User107
NA
28
17.6k
show selected items as comma separated in multi dropdown
Sep 15 2016 4:55 AM
How can i show the selected items as comma separated in the Multi select dropdown text field in asp.net
In my web application, i am trying to do show the selected items as comma separated in the Multi select drop down text field is it possible to do and how can i do this can any one tell me.
I tried:
protected void dropdown1_SelectedIndexChanged(object sender, EventArgs e)
{
string element= string.Empty;
foreach(ListItem item in dropdown1.Items)
{
if (item.Selected)
element += "'" + item.Value + "',";
}
if (element.Length > 0)
{
element = element.Substring(0, element.Length - 1);
string qry = "select * from Selections where col1= '" + dropdowncol1.SelectedValue.ToString() + "' and col2 in (" + element+ ")";
SqlCommand cmd = new SqlCommand(qry, con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
dropdown1.DataTextField = element;
}
Can anyone help me to how to do this.
Thank you
Reply
Answers (
3
)
How do I change the column header of a GridView into 2 rows?
[URGENT] Unable to launch asp.net web application