Results 1 to 3 of 3

Thread: Dynamic drop down list - event handling problem

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    43

    Dynamic drop down list - event handling problem

    Hi Guys,

    I have written a fragment of code that basically displays the text box if the drop down box (selected item.value) = 1 or 2 otherwise it will not display the text box.
    it works fine for the static drop down box


    but same thing is not working if the drop down list is dynamic. It always post back the first value. Can any one kindly explain me what I am missing here??

    here is my code....................

    private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)

    {

    string GetDataFromDD;

    if (!IsPostBack)

    {

    GetDataFromDD = DropDownList1.SelectedItem.Value.ToString();

    }

    else

    {

    GetDataFromDD = DropDownList1.SelectedItem.Value.ToString();

    }


    Response.Write(GetDataFromDD);

    switch(GetDataFromDD)

    {

    case "1":

    TextBox1.Visible = true;

    break;

    case "2":

    TextBox1.Visible = true;

    break;

    case "3":

    TextBox1.Visible = false;

    break;

    case "4":

    TextBox1.Visible = false;

    break;


    }


    }

    Thanks in advance,

    dummy
    ***learning everyday ***

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    I answered this on the other forum you posted it on.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    43
    Thanks,

    As I needed an answer urgently I posted it different forums

    Cheers
    ***learning everyday ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width