DataGrid with Dropdown list

Discussion in 'ASP .Net Datagrid Control' started by vijay_kerji@yahoo.com, Feb 18, 2005.

  1. Guest

    Any Help is appreciated!
    I have a datagrid with Drop down list and a remove hyperlink as two
    columns.
    When I remove the row of the datagrid by clicking on the remove
    column,Dropdown list is mentaining its previous state.
    i.e Removed dropdownlist's selected value is applied to the next
    datagrid item's dropdown list.

    DATAGRID
    ---------------------------------------------------------
    "Remove" | "<DropDownList1>"
    ---------------------------------------------------------
    "Remove" | "<DropDownList2>""


    When the first row is removed, "DropDownList2" becomes
    "DropDownList1"!!!

    How to solve this problem?

    Thanks
    Vijay
     
    , Feb 18, 2005
    #1
    1. Advertisements

  2. Samuel Kim

    Samuel Kim Guest

    Can you pls post some of the code you are using?
     
    Samuel Kim, Feb 19, 2005
    #2
    1. Advertisements

  3. Samuel Kim

    Samuel Kim Guest

    Can you pls post some of the code you are using?
     
    Samuel Kim, Feb 19, 2005
    #3
  4. Vijay Kerji

    Vijay Kerji Guest

    "Samuel Kim" <> wrote in message news:<>...
    > Can you pls post some of the code you are using?


    Hi,
    The following code is used in the 'remove' hyperlink click handler.

    foreach(DataGridItem DemoGridItem in dataGrid_AddUsers.Items)
    {
    DropDownList myDDList =
    (DropDownList)DemoGridItem.Cells[3].Controls[1];
    string selectedValue =
    ((DataGridUser)this.userList[index]).userRole;
    //Check if the program is in edit or create
    //If it is in edit, disable the datagrid item row and do not add
    PM as dropdownlist item.
    if ("ProgramEdit" == programModeValue)
    {
    if(selectedValue == "PM")
    {
    myDDList.Items.Add("PM");
    DemoGridItem.Enabled = myDDList.Enabled = false;
    myDDList.Items.FindByText(((DataGridUser)this.userList[index]).userRole).Selected
    = true;
    //myDDList.SelectedValue
    =((DataGridUser)this.userList[index]).userRole;
    } //if the role is null which is a bug in DB
    else if (selectedValue == "")
    {
    myDDList.Items.Add("Sub PM");
    myDDList.Items.Add("CBA");
    myDDList.Items.Add("Stake Holder");
    }
    else //since we are in edit mode, add all except PM
    {
    myDDList.Items.Add("Sub PM");
    myDDList.Items.Add("CBA");
    myDDList.Items.Add("Stake Holder");
    myDDList.Items.FindByText(((DataGridUser)this.userList[index]).userRole).Selected
    = true;
    //myDDList.SelectedValue
    =((DataGridUser)userList[index]).userRole;
    }
    }
    else //we are in create mode, add all the values to the list.
    {
    myDDList.Items.Add("PM");
    myDDList.Items.Add("Sub PM");
    myDDList.Items.Add("CBA");
    myDDList.Items.Add("Stake Holder");
    //set the selected value
    myDDList.Items.FindByText(((DataGridUser)this.userList[index]).userRole).Selected
    = true;
    //myDDList.SelectedValue
    =((DataGridUser)userList[index]).userRole;
    }
    index++;
    }

    Hope it is readable.

    Thanks

    Vijay
     
    Vijay Kerji, Feb 21, 2005
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michelle

    bounding for dropdown list in datagrid

    Michelle, Jul 7, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    513
    [ MVP ] Sukesh Ashok Kumar
    Jul 12, 2003
  2. vishnu
    Replies:
    1
    Views:
    1,422
    Patrick.O.Ige
    Mar 25, 2006
  3. =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=

    Dropdown List - Check if value exists in list prior to selection

    =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=, Mar 10, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    2,180
    =?Utf-8?B?QnJlbmRlbg==?=
    Mar 20, 2007
  4. =?Utf-8?B?RGF2ZSBU?=

    Columns in Dropdown list and list box

    =?Utf-8?B?RGF2ZSBU?=, Jun 25, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    594
    jufemaiz: jc
    Jun 27, 2007
  5. mldardy
    Replies:
    1
    Views:
    885
    mldardy
    Dec 10, 2008
  6. M. Craig

    How to set background color of List item in dropdown list

    M. Craig, Nov 12, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    430
    M. Craig
    Nov 12, 2003
  7. M. Craig
    Replies:
    1
    Views:
    922
    Victor Garcia Aprea [MVP]
    Jan 9, 2004
  8. Bryan Stauffer

    Dropdown List doesn't know what's in it's list

    Bryan Stauffer, Jul 6, 2006, in forum: ASP .Net Web Controls
    Replies:
    6
    Views:
    237
Loading...