then do this :
protected void Check_Click(object sender, EventArgs e)
{
if (TextBox1.Text.Trim().ToLower() == "apple")
{
if (DropDownList1.Items.FindByValue(TextBox1.Text.Trim()) != null)
{
var index =
DropDownList1.SelectedIndex =
DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(TextBox1.Text.Trim()));
DropDownList1.Items[index].Text = "RedFruit";
Label1.Text = TextBox1.Text + " is changed to RedFruit";
}
}
else
{
if (DropDownList1.Items.FindByValue(TextBox1.Text.Trim()) != null)
{
Label1.Text = TextBox1.Text + " Exists";
}
else
{
Label1.Text = "Not Exist !";
}
}
}
it will change only apple to redfruit , if apple exist , more over it will check for other items too , do they exist or not ?