G
Guest
Can some please tell me why this dropdown list isn't getting populated in my
datagrid! I don't get any error the datagrid just doesn't populate. I would
appritiate any examples.
Thanks
...::Inline Code
<FooterTemplate>
<!-- Pull Office Names from Database -->
<aspropDownList id="DDLaddOffice" runat="server"></aspropDownList>
</FooterTemplate>
...::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("strConn"))
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("DDLaddOffice"),
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
datagrid! I don't get any error the datagrid just doesn't populate. I would
appritiate any examples.
Thanks
...::Inline Code
<FooterTemplate>
<!-- Pull Office Names from Database -->
<aspropDownList id="DDLaddOffice" runat="server"></aspropDownList>
</FooterTemplate>
...::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("strConn"))
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("DDLaddOffice"),
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