Problem binding data to datalist

L

Laura K

Can someone tell me where I went wrong. This is my code for binding data to
a datalist.

<script language="vb">
Sub Page_Load(Src As Object, e As EventArgs)

Dim Con As New SqlConnection("server=(PathToDataBase)"; &
"database=name;User ID=UID;Password=password")
Dim myCommand As New SqlDataAdapter
myCommand= ("select distinct strSubCategory from tblProducts", con)

Dim dgDataset = New DataSet()
myCommand.Fill(dgDataset)

datalist.DataSource = ds
datalist.DataBind()

end sub
</script>

<asp:DataList id="datalist" runat="server" HorizontalAlign="Center">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "strSubCategory") %>
</ItemTemplate>
</asp:DataList>
 
K

Karl Seguin

Do you get an error?

You are missing runat="server" in the <script> tag....
you aren't binding to dgDataSet...

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top