I'd appreciate any help anyone can give with this. I'm building an administrative page which allows the user to insert URLs and text into a database making it easier for them to update their (separate) website. As part of this admin page, I've got a datagrid displaying their data. Since their website can have multiple pages, selected from a querystring, I need to update any changes to the database using the page identity (pageID), instead of the more user friendly pagename. I've been looking at this so long, I'm sure I'm missing something obvious, but I cannot get the dropdownlist to populate with anything. I've checked the SQL, there are 3 records that should be returned with that syntax. I would really appreciate another pair of eyes to look at the following code and let me know where I'm screwing it up. Thanks
Code:
<asp:datagrid id="dgLinks" runat="server" Width="100%" OnEditCommand="DgLinks_Edit" OnCancelCommand="dgLinks_Cancel"
OnUpdateCommand="dgLinks_Update" OnDeleteCommand="dgLinks_Delete"
DataKeyField="id"
AutoGenerateColumns="False"
OnItemDataBound="dgLinks_Build">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn>
<asp:BoundColumn DataField="URL" HeaderText="URL"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Displayed on">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.PageName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlPages" Runat="server" DataValueField="pageid" DataTextField="PageName" DataSource="<%# GetPages() %>">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="LinkText" HeaderText="Link Text"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Add'l Text">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Description") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="addlText" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container, "DataItem.Description") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
Public ddlDataSet As DataSet = New DataSet
Function GetPages() As DataSet
Dim strsql As String = "Select PageID, PageName from DepartmentPage where DepartmentID=1"
SqlConnection1.Open()
Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter(strsql, SqlConnection1)
myDataAdapter.Fill(ddlDataSet, "Pages")
SqlConnection1.Close()
Return ddlDataSet
End Function