Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem binding data to datalist

Reply
Thread Tools

Problem binding data to datalist

 
 
Laura K
Guest
Posts: n/a
 
      03-25-2005
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>

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


 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      03-26-2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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>
>
> <aspataList id="datalist" runat="server" HorizontalAlign="Center">
> <ItemTemplate>
> <%# DataBinder.Eval(Container.DataItem, "strSubCategory") %>
> </ItemTemplate>
> </aspataList>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data not binding to datalist Laura K ASP .Net 5 12-29-2005 05:48 AM
Complex data binding question, binding child objects of a custom collection. JcFx ASP .Net Datagrid Control 0 06-01-2005 04:01 PM
binding XML data to the datalist control buran ASP .Net 0 04-28-2005 06:58 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
Data Binding - using inline code vs. functions vs. straight binding Jordan ASP .Net 2 02-10-2004 08:32 PM



Advertisments