Aalhussein

Aalhussein

  • 1.6k
  • 133
  • 10.1k

Diff in ddl.SelectedValue vs ddl.SelectedItem.Value

Apr 5 2020 9:12 AM

Hi,

I get confused between  the property of drop down list,
not sure when to use either one, I run into issues when using  ddl.SelectedItem.Value, but when I use ddl.SelectedValue  it solve the problem and I am able to get the value.
 
Please advise 

 

if (ddlOwner.SelectedItem.Value == "1")   {

lblOutput.Text = "Please select Owner !";

lblOutput.ForeColor = System.Drawing.Color.Red;

ddlOwner.Focus();

return;
}

 
VS
 
if (ddlOwner.SelectedValue == "1") {

lblOutput.Text = "Please select Owner !";

lblOutput.ForeColor = System.Drawing.Color.Red;

ddlOwner.Focus();

return;
}

 
 Al

Answers (3)