468,115 Members | 2,024 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,115 developers. It's quick & easy.

Problem binding data to datalist

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>
Nov 19 '05 #1
1 1130
Do you get an error?

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

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Laura K" <kl*******@ATcharter.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
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>

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.