Hello, I'm using DataBind for show a column of SQL DB in a DropDownList.
The program works but when I change the case of DropDownList, this issue appear.
void ddlTurno()
{
ddlTablas.DataSource = null;
ddlTablas.DataBind();
SqlConnection con = new SqlConnection(connectionString);
string com = "Select DISTINCT Turno from ee";
SqlDataAdapter adpt = new SqlDataAdapter(com, con);
DataTable dt = new DataTable();
adpt.Fill(dt);
ddlTablas.DataSource = dt;
ddlTablas.DataBind();
ddlTablas.DataTextField = "Turno";
ddlTablas.DataValueField = "Turno";
ddlTablas.DataBind();
PopulateGridview();
}
void ddlNivel()
{
ddlTablas.DataSource = null;
ddlTablas.DataBind();
SqlConnection con = new SqlConnection(connectionString);
string com = "Select DISTINCT Nivel from ee";
SqlDataAdapter adpt = new SqlDataAdapter(com, con);
DataTable dt = new DataTable();
adpt.Fill(dt);
ddlTablas.DataSource = dt;
ddlTablas.DataBind();
ddlTablas.DataTextField = "Nivel";
ddlTablas.DataValueField = "Nivel";
ddlTablas.DataBind();
PopulateGridview();
}
protected void ddlCondicion_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlCondicion.SelectedValue == "Turno")
{
ddlTurno();
}
if (ddlCondicion.SelectedValue == "Nivel")
{
ddlNivel();
}
}
If I select first "Turno" in DDL and then "Nivel" the error message is:
'System.Data.DataRowView' does not contain a property with the name 'Turno'
But if first I select "Nivel", then "Turno" the message is:
'System.Data.DataRowView' does not contain a property with the name 'Nivel'