Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

exclude dinamic value from listbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mirnes - 22 Jun 2007 10:01 GMT
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.
Milosz Skalecki [MCAD] - 22 Jun 2007 10:47 GMT
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
Signature

Milosz

> 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.
Mirnes - 25 Jun 2007 07:59 GMT
Thanks for response, I'll try this.

Milosz Skalecki [ MCAD ] je napisao:
> Hi Mirnes,
>
[quoted text clipped - 22 lines]
> > added from listbox. Since it is impossible to do in query which is
> > datasource for query is there some other option.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.