I am needing to update the value of one drop down list based off the selection from a different drop down list. The caveat that I have is instead of the drop down list containing the actual value displayed on the page, it is holding the id assigned, which skews my whole logic behind it! I am wanting to update ddlLocation based off the value selected for ddlCompName on the page itself ddlCompName holds a text value like On1, On2, On3, On4 but behind the scenes it is actually housing the value of CompID
This is how ddlCompName gets populated
private void GetComputerName()
{
this.ddlCompName.DataSource = GetFloorPlanSeats(DBToQuery);
this.ddlCompName.DataTextField = ComputerName;
this.ddlCompName.DataValueField = CompID;
this.ddlCompName.DataBind();
}
And this is the update I want to run, but doesn't work due to the numeric value
protected void ddlCompName_SelectedIndexChanged(object sender, EventArgs e)
{
if (VBS.Left(ddlCompName.SelectedValue.ToString(), 2) == "On")
{
ddlLocation.SelectedValue = "Main Building";
}
}
What do I need to alter so that I can make the update as desired?
Aucun commentaire:
Enregistrer un commentaire