I need to set the selected value in a drop down list to match the value from a database record so that the record can remain the same or be changed before submitting an update. How can I get the control to ignore the case of the text when setting the selected value? If my database record value doesn't match the entries in the drop down list exactly, I don't get a match. The only way I can get it to work is if I convert both side to upper or lower case. How can I get it to ignore the case?
Protected Sub Branches_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles Branches.ItemDataBound
If e.Item.ItemType = ListItemType.EditItem Then
Dim tbID As TextBox = CType(e.Item.FindControl("tbID"), TextBox)
Dim objBranch As New Branch
Dim ds As New DataSet
objBranch = objDataAccess.getBranch(tbID.Text)
Dim LinkButtonDelete As LinkButton = CType(e.Item.FindControl("LinkButtonDelete"), LinkButton)
Dim ddlEditRegion As DropDownList = CType(e.Item.FindControl("ddlEditRegion"), DropDownList)
ds = objDataAccess.getRegions
ddlEditRegion.DataSource = ds.Tables(0)
ddlEditRegion.DataTextField = ds.Tables(0).Columns("Region").ColumnName.ToString
ddlEditRegion.DataValueField = ds.Tables(0).Columns("Region").ColumnName.ToString
ddlEditRegion.DataBind()
ddlEditRegion.Items.Insert(0, "")
ddlEditRegion.SelectedValue = objBranch.Region.ToString.ToUpper
Utilities.CreateConfirmBox(LinkButtonDelete, _
"Delete Branch?")
End If
End Sub