Quote:Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized. Line 203: sqlCmd.Parameters.AddWithValue("@FieldID", DropDownList_PersonField.SelectedValue); Line 204: sqlCmd.Connection = con; Line 205: con.Open(); Line 206: SqlDataAdapter da = new SqlDataAdapter(sqlCmd); Line 207: DataTable dt = new DataTable(); Source File: e:\Final Project\FindEeasyJobs\ManagePersons.aspx.cs Line: 205
protected void DropDownList_PersonField_SelectedIndexChanged(object sender, EventArgs e) { try { using (SqlCommand sqlCmd = new SqlCommand()) { sqlCmd.CommandText = "select SubField_ID,SubField_Name_english FROM SubField_TB WHERE Field_ID=@FieldID"; sqlCmd.Parameters.AddWithValue("@FieldID", DropDownList_PersonField.SelectedValue); sqlCmd.Connection = con; con.Open(); SqlDataAdapter da = new SqlDataAdapter(sqlCmd); DataTable dt = new DataTable(); da.Fill(dt); DropDownList_PersonSubField.DataSource = dt; DropDownList_PersonSubField.DataValueField = "SubField_ID"; DropDownList_PersonSubField.DataTextField = "SubField_Name_english"; DropDownList_PersonSubField.DataBind(); con.Close(); //Adding "Please select SubField" option in dropdownlist DropDownList_PersonSubField.Items.Insert(0, new ListItem("Please select your field", "0")); } } catch (System.Data.SqlClient.SqlException ex) { string msg = "Fetch Error:"; msg += ex.Message; throw new Exception(msg); } }//-------------------end of selectindexchanged
con
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)