468,537 Members | 1,899 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,537 developers. It's quick & easy.

exclude dinamic value from listbox

I have a listbox which is populated from Sql query and I use it to add
values to table. I would like to exclude value which just has been
added from listbox. Since it is impossible to do in query which is
datasource for query is there some other option.

Jun 22 '07 #1
2 1487
Hi Mirnes,

You have to handle DataBound of the ListBox event and remove whatever you
don't need:

protected void ListBox1_DataBound(object sender, EventArgs e)
{
ListBox listBox = (ListBox)sender;
// there are two methods you can use
//ListItem listItem = listBox.Items.FindByText("ItemText");
// or
ListItem listItem = listBox.Items.FindByValue("3");
if (listItem != null)
{
listBox.Items.Remove(listItem);
}
}
hope this helps
--
Milosz
"Mirnes" wrote:
I have a listbox which is populated from Sql query and I use it to add
values to table. I would like to exclude value which just has been
added from listbox. Since it is impossible to do in query which is
datasource for query is there some other option.

Jun 22 '07 #2
Thanks for response, I'll try this.
Milosz Skalecki [ MCAD ] je napisao:
Hi Mirnes,

You have to handle DataBound of the ListBox event and remove whatever you
don't need:

protected void ListBox1_DataBound(object sender, EventArgs e)
{
ListBox listBox = (ListBox)sender;
// there are two methods you can use
//ListItem listItem = listBox.Items.FindByText("ItemText");
// or
ListItem listItem = listBox.Items.FindByValue("3");
if (listItem != null)
{
listBox.Items.Remove(listItem);
}
}
hope this helps
--
Milosz
"Mirnes" wrote:
I have a listbox which is populated from Sql query and I use it to add
values to table. I would like to exclude value which just has been
added from listbox. Since it is impossible to do in query which is
datasource for query is there some other option.
Jun 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by dddddd | last post: by
3 posts views Thread by Jose Garcia | last post: by
6 posts views Thread by gp | last post: by
2 posts views Thread by Remco Groot Beumer | last post: by
2 posts views Thread by Allan Horwitz | last post: by
3 posts views Thread by Gabe Matteson | last post: by
2 posts views Thread by php_Boi | last post: by
10 posts views Thread by Simon Brooke | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.