Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code as follows

Value for course Fees & Time spent by student Dropdownlist1

In the dropdownlist selected item four values will be display as follows

Excellent
Good
Fair
Poor

In the above dropdownlist1 when we select the Poor only from the dropdownlist1 that time modalpopup extender popup will be display.
In the modalpopup extenderpopup one textbox will be there type for the Poor reason and click the ok button.

C#
  int currentddl = -1;
  string SelectedDropdown = string.Empty; 


  protected void Dropdownlist1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (Dropdownlist1.SelectedItem.ToString() == "Poor")
        {
            ModalPopupExtender1.TargetControlID = "Dropdownlist1";
            TxtNegativeFeedback.Text = "";
            currentddl = 0;
            SelectedDropdown = "ddlcourse";
            hfnegativefeedback.Value = currentddl.ToString();
            Negativepnlpopup();
            Negativepnlpopupfalse();
        }
    }
  
  private void Negativepnlpopup()
    {        
            ModalPopupExtender1.TargetControlID = SelectedDropdown.ToString();
            ModalPopupExtender1.Show();
            Pnlnegativefeedback.Visible = true;
    }
  

 private void Negativepnlpopupfalse()
    {
        if (Dropdownlist1.SelectedItem.ToString() == "Excellent")
        {
            Pnlnegativefeedback.Visible = false;
            return;
        }

        if (Dropdownlist1.SelectedItem.ToString() == "Very Good")
        {
            Pnlnegativefeedback.Visible = false;
            return;
        }

        if (Dropdownlist1.SelectedItem.ToString() == "Good")
        {
            Pnlnegativefeedback.Visible = false;
            return;
        }

        if (Dropdownlist1.SelectedItem.ToString() == "Fair")
        {
            pnlPopup.Visible = false;
            return;
        }
}


In the run mode when we select the Dropdownlist1 in that dorpdownlist1 suppose i select the Good that time modalpopupextender will show.
i don't want to display the modalpopupextender. only when i select the Poor in the dropdownlist1 that time only modalpopupextender will be visible.

for that i written the code.

But my code what is the mistake i made?

Please help me.

Regards,
narasiman P.
Posted
Updated 6-Nov-13 20:17pm
v3
Comments
Please check my answer.

1 solution

Refer - [MSDN] ListControl.SelectedItem Property[^].
Quote:
Gets the selected item with the lowest index in the list control.
It gets you the SelectedItem which has two properties Text and Value.

As you are checking with Text, so your code should be like...
C#
if (Dropdownlist1.SelectedItem.Text == "Poor")
{
    // Your code here.  
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900