Can someone please tell me why this doesn't work! I have a datagrid with a
dropdown menu in the footer but for some reason the dropdown just doesn't
populate with data!
I'm not really sure what I'm doing wrong!
Do I need to run the sub from page_load??? If so how???
Thanks for any advice!
...CODEBEHIND
Private Sub populateDDL_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)
'Construct the Database Connection
Dim Myconn As New
SqlConnection(ConfigurationSettings.AppSettings("s trConn"))
Dim cmd As New SqlCommand("SelectOffice", Myconn)
If e.Item.ItemType = ListItemType.Footer Then
cmd.CommandType = CommandType.StoredProcedure
Myconn.Open()
Dim add_Office As DropDownList
'Payment Method Dll - create, fill and preselect
add_Office = CType(e.Item.FindControl("add_Office"), DropDownList)
add_Office.DataSource =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
add_Office.DataBind()
add_Office.Items.Insert(0, "Select One")
add_Office.Items.FindByText("Select One").Value = 0 'insert
don't create a value, but we need a value during defaults
add_Office.SelectedIndex = 0
End If
End Sub