Results 1 to 5 of 5

Thread: DropDown in DataList

  1. #1

    Smile DropDown in DataList

    I have datalist and in the Item template i have taken a dropdown list in a ASP.NET 1.1 web application. I have populated the dropdown at runtime. Now i want to capture the value selected in the DropDown. I tried SelectedIndexChanged procedure of the DropDown and the DataList and ItemCommand of DataList but to no avail. These events are being fired but i have no clue on how to capture the value selected in the DropDown List..... When an item in the drop Down is selected then the ItemCommand event of the datalist isnt triggered.....Please Help.

    Thanks in Advance.
    Sreedevi


    Last edited by Sreedevi Pidaparthi; 06-26-2007 at 11:23 AM.

  2. #2
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: DropDown in DataList

    Check whether the ValueField has unique values or not....

    -------------------
    suresh


  3. #3
    Junior Member
    Join Date
    Jun 2009
    Answers
    1

    Re: DropDown in DataList

    protected void drp1_SelectedIndexChanged(object sender, EventArgs e)
    {
    DropDownList ddl = (DropDownList)sender;

    string contactid = ddl.SelectedIndex.ToString();


    // to access any other element in datalist
    // DataListItem row = ddl.NamingContainer as DataListItem;

    //Label lbl = (Label)row.FindControl("lbl_text");

    if (ddl.SelectedItem.Text != "-Select-")
    {
    ....
    }
    else
    {

    }
    }

    }


  4. #4

    Re: DropDown in DataList

    protected void drp1_SelectedIndexChanged(object sender, EventArgs e)
    {
    string selectedValue=drp1.SelectedValue.ToString().Trim();

    //Do rest of the code

    }

    this will help u to get the selected value from the drop down list


  5. #5
    Junior Member
    Join Date
    Aug 2009
    Answers
    1

    Re: DropDown in DataList

    protected void drp1_SelectedIndexChanged(object sender, EventArgs e)
    {
    DropDownList ddl = (DropDownList)sender;

    string contactid = ddl.SelectedIndex.ToString();


    // to access any other element in datalist
    // DataListItem row = ddl.NamingContainer as DataListItem;

    //Label lbl = (Label)row.FindControl("lbl_text");

    if (ddl.SelectedItem.Text != "-Select-")
    {
    ....
    }
    else
    {

    }
    }

    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact