Hussain Javed

Hussain Javed

  • NA
  • 0
  • 12k

drpdn SelectedValue is invalid because not exist in list

Sep 15 2015 6:26 AM
here is my code
protected void ddlDDLQualifi()
{
try
{
//open the db connection if it is closed...
if (con.State == ConnectionState.Closed)
con.Open();
cmd = new SqlCommand();
cmd.CommandText = "sp_Get_Qualification";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
DDLQualifi.DataSource = cmd.ExecuteReader();
DDLQualifi.DataTextField = "Education_Type";
DDLQualifi.DataValueField = "Education_Id";
DDLQualifi.DataBind();
DDLQualifi.Items.Insert(0, new ListItem("--Select--", "0"));
}
catch (Exception ex)
{
throw ex;
}
finally //Close db Connection if it is open....
{
if (con.State == ConnectionState.Open)
con.Close();
}
}
 the value is binded and it shows value when i saw while debugging but it shows error like this"DDLQualifi' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value"
 
 
 
 

Answers (1)