wrote:
> dear all,
> i have a listbox whose items are displayed in listbox e.g
> ('1','3','4',)
> my problem is the last comma (, after 4) i don't want this comma as i
> have to use
> this string in sql query.
> the loop through procedure is this
>
> protected void Button1_Click1(object sender, EventArgs e)
> {
> string msg = "";
>
> foreach (ListItem li in listboxcategory.Items)
> {
> if (li.Selected == true)
> {
> msg += "'" + li.Value + "'" + ",";
> }
> }
> Label1.Text = "("+ msg + ")";
> }
>
> thanks in advance
>
You can use substring on the variable msg after the loop to remove the
trailing comma.