Problem in Setting SelectedValue for DropdownList in Form

Discussion in 'ASP .Net Web Controls' started by Charleees, Dec 30, 2005.

  1. Charleees

    Charleees Guest

    Hi all,
    I have a Problem in Setting the Dropdown selected value.

    I have a Page where i get the input for the number of rows and columns
    and generate a dynamic table on another page ie) table page.
    If i select edit button in table page , the page is redirected to Input
    page .
    In the input page i have a panel where i have 6 dropdown, which
    indicates the Colspan and Rowspan Cordinates and number of Rows and Col
    Spaans.
    The problem is when i click the edit button, i have to set the selected
    value of these dropdowns to some values ie) the table properties .
    If the tables row is 3 and Column is 4 , i have to set the row_ddl to 3
    and also column_ddl to 4.

    I assidn the selected value for these dropdowns as

    ddl.selectedvalue = "value"

    when i debug , i was getting the right values in the line , but thses
    changes are not reflected in the Form.
    I am filling the Ddl in Pageload and only if !(page.Ispostback).

    Can any one help me please..........

    Thanks in advance
     
    Charleees, Dec 30, 2005
    #1
    1. Advertising

  2. Whatever changes to the dropdownlist that you did during the Page_Load will
    be lost if the dropdownlist is databound to a datasource. You should set the
    selected value of the dropdownlist during the DataBound event.

    void column_dll_DataBound(object sender, EventArgs e)
    {
    //set here the selectedvalue
    ListItem li = ((DropDownList)sender).Items.FindByValue("4");
    if (li != null) //item was found that has the selected value
    {
    ((DropDownList)sender).ClearSelection(); //clear the old
    selection first
    li.Selected = true; //set the new selection
    }
    }
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Charleees" wrote:

    > Hi all,
    > I have a Problem in Setting the Dropdown selected value.
    >
    > I have a Page where i get the input for the number of rows and columns
    > and generate a dynamic table on another page ie) table page.
    > If i select edit button in table page , the page is redirected to Input
    > page .
    > In the input page i have a panel where i have 6 dropdown, which
    > indicates the Colspan and Rowspan Cordinates and number of Rows and Col
    > Spaans.
    > The problem is when i click the edit button, i have to set the selected
    > value of these dropdowns to some values ie) the table properties .
    > If the tables row is 3 and Column is 4 , i have to set the row_ddl to 3
    > and also column_ddl to 4.
    >
    > I assidn the selected value for these dropdowns as
    >
    > ddl.selectedvalue = "value"
    >
    > when i debug , i was getting the right values in the line , but thses
    > changes are not reflected in the Form.
    > I am filling the Ddl in Pageload and only if !(page.Ispostback).
    >
    > Can any one help me please..........
    >
    > Thanks in advance
    >
    >
     
    Phillip Williams, Dec 30, 2005
    #2
    1. Advertising

  3. Charleees

    Charleees Guest

    hi

    i dont have to do anything like databound
    i have just 10 values in my dropdown and i have to set according to the
    variables values i assign

    if i tell 2 then the selected value should be to 1

    if i do this i could not set the value i selected

    i get some defaults

    what should i do

    when i assign i get right values ( i checked in debug mode)

    please help
     
    Charleees, Dec 30, 2005
    #3
    1. Advertising

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. Tom Jorgenson
    Replies:
    3
    Views:
    7,031
  2. Thomas Kern
    Replies:
    1
    Views:
    412
    =?Utf-8?B?YWxhc3Bpbg==?=
    Nov 9, 2004
  3. Ben
    Replies:
    0
    Views:
    3,342
  4. David C

    Setting DropDownList SelectedValue

    David C, Nov 20, 2007, in forum: ASP .Net
    Replies:
    9
    Views:
    655
    Scott Roberts
    Nov 21, 2007
  5. K Bryan
    Replies:
    0
    Views:
    106
    K Bryan
    Apr 14, 2004
Loading...

Share This Page