Tuesday, February 19, 2013

DropDownList set dl.SelectedValue


 Private Sub dg_srvc_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg_srvc.ItemDataBound
        If e.Item.ItemType = ListItemType.EditItem Then
            Dim dl_span As DropDownList
            Dim t As Label

            dl_span = CType(e.Item.FindControl("dl_span"), DropDownList)
            dl_span.SelectedValue = dl_span.Items.IndexOf(dl_span.Items.FindByText(s_span.Trim.ToLower))

            t = CType(e.Item.FindControl("temp"), Label)
            t.Text = s_span.Trim

        End If

WARNING: ENSURE your values if hard coded match the value from the DB...

No comments: