Click here to Skip to main content
15,920,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one list box in that item having separated by ',' like (It software,Hardware,Banking,accounts) these are all coming from grid view check items and I have one check box when i click on that I want add own items that items also I want to display like ',' (not in next line) I want add items only single line separated by ','

I wrote coding for gridview check box adding in list box with separated by ','


protected void chkcheckquery_CheckedChanged(object sender, EventArgs e)
    {
        
       
        try
        {
            sb = new StringBuilder();
            foreach (GridViewRow gr in gvqueriescheck.Rows)
            {
                if (((CheckBox)gr.FindControl("chkcheckquery")).Checked == true)
                {
                    sb.Append(gr.Cells[1].Text + ",");

                }
            }
            ListBox1.Items.Clear();
            ListBox1.Items.Add(sb.ToString())
        }
        catch (Exception ex)
        {
            lblmessage.Text = ex.Message;
        }

    }


and below gridview I have text box I will enter anything in textbox I want to add in listbox with ','


[Edited]Code is Wrapped in "pre" tag[/Edited]
Posted
Updated 28-Jan-11 2:24am
v4
Comments
Abhinav S 28-Jan-11 8:14am    
Where do you face a problem?
Rupa1 28-Jan-11 8:16am    
gridview checked items adding in listbox working fine ,after gridview i ve one text box i want to add that text also in list box with ','

1 solution

It's not quite clear.
You can add it same way, like
ListBox1.Items.Add(textBox1.Text):


Or am I missing something?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900