1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

List box controls- not showing updated one.

Discussion in 'C#' started by ksenthil, Mar 7, 2007.

  1. #1
    I got two list boxes when page loads I have to eliminate the items in the first list box if second list box has the same item. Please see the below code. Even I removed it, still shows on the first list box. Please anyone can help me. Thanks.

    Event: Page_Load

    // First list box
    lstUser.DataValueField = "Id";
    lstUser.DataTextField = "Name";
    lstUser.DataSource = GetUsersByUserType(cp.Department.DepartmentId, UserTypes.Employee);
    lstUser.DataBind();

    //Second list box
    lstUserAdded.DataValueField = "Id";
    lstUserAdded.DataTextField = "Name";
    lstUserAdded.DataSource = GetAddedUsers();
    lstUserAdded.DataBind();


    // Here I am removing the items on the first list box.
    foreach (ListItem item in lstUserAdded.Items)
    {
    lstUser.Items.Remove(item);
    }
    //After removing the items on the first list box, the removed items still showing on the first list box when page loads is complete.
     
    ksenthil, Mar 7, 2007 IP
  2. ztoma

    ztoma Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    we'll need more info.

    understand, that the contents of the listbox remain within the viewstate even though you wouldn't add the to the list on every post back..
     
    ztoma, Mar 7, 2007 IP