protected void ddlLocation_SelectedIndexChanged1(object sender, EventArgs e) { connectionManger = new ConnectionManger(); string QueryForCascading = "SELECT CanteenId, CanteenName FROM Canteen WHERE LocationId = " + ddlLocation.SelectedValue; DataSet dataSet = connectionManger.Fill(QueryForCascading); if (dataSet.Tables[0].Rows.Count > 0) { ddlCanteen.DataSource = dataSet.Tables[0]; ddlCanteen.DataTextField = "CanteenName"; ddlCanteen.DataValueField = "CanteenId"; ddlCanteen.DataBind(); ddlCanteen.Items.Insert(0, "--Select--"); } }
private void AutoFillLoc() { connectionManger = new ConnectionManger(); string QueryForAutoFillingLoc = "SELECT LocationId, LocationName FROM Location"; DataSet dataSet = connectionManger.Fill(QueryForAutoFillingLoc); if (dataSet.Tables[0].Rows.Count > 0) { ddlLocation.DataSource = dataSet.Tables[0]; ddlLocation.DataTextField = "LocationName"; ddlLocation.DataValueField = "LocationId"; ddlLocation.DataBind(); //ddlLocation.Items.Insert(0, "--Select--"); } }