473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1309
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: julk | last post by:
ok im new to C# so please help. i know it is simple but hey im a rooke. the problme i am having is that i drag a DataList control into my form (webpage-.aspx) then i got o the HTML side of the...
3
by: bbernieb | last post by:
Hi, All, Is it possible to access a variable inside of a data binding, without the variable being out of scope? (Note: On the DataBinder line, I get an error message that says "Name 'i' is...
0
by: s.gregory | last post by:
My page layout is like this: Page >DataList (databound using ObjectDataSource1 contained in page) >>Items >>>UserControl >>>>GridView (databound using another ObjectDataSource2 contained in...
5
by: Laura K | last post by:
I am having difficulty binding data to my datalist. The data list does not show. I have gone round and round for two days. I could really use some help looking through this code and seeing where...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.