Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 7th, 2005, 10:31 AM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
Default databound headertemplate

Hi,

I am binding a datalist from sql. In sql i have a table with the following fields:
prodID,ProductName, CategoryName

I want my datalist to look as follows (but it doesn't):
CategoryNameA =Header
Product 1 =ItemTemplate
Product 2
-------------
CategoryNameB=Headertemplate (from database)
Product 3 =ItemTemplate
Product 4

However, I get the following result:
CategoryNameA =Header
Product 1 =ItemTemplate
Product 2
Product 3
Product 4

I have a datalist such as the following:
<asp:datalist id="PicList" runat="server" Font-Names="Arial" Font-Size="Smaller">
<HeaderTemplate>
<%# dt.Rows(0).Item( "CategoryName") %>
</HeaderTemplate>
<ItemTemplate>
<TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0'>
<TR>
<TD dir='rtl' valign="top">
<%# ImgExist(Container.DataItem("ProductName")) %>
</TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:datalist>


 Dim cmd As SqlCommand

        cmd = objConn.CreateCommand

        cmd.CommandText = "SELECT * FROM CATEGORY INNER JOIN Product ON IDCATEGORY=CATID ORDER BY CATEGORYNAME"



        Dim da As New SqlDataAdapter(cmd)

        dt = New DataTable("ads")



        da.Fill(dt)



        If dt.Rows.Count = 0 Then

            PicList.Visible = False

        Else : PicList.Visible = True

        End If

        PicList.DataSource = dt

        PicList.DataBind()




Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databound Dropdown fullingdale ASP.NET 2.0 Basics 2 June 20th, 2008 02:33 AM
Getting a databound value from datalist contrrol almotions ASP.NET 2.0 Basics 8 April 23rd, 2008 09:00 AM
Findcontrol in headertemplate of datagrid S_Dogra ASP.NET 1.0 and 1.1 Professional 1 January 4th, 2007 03:41 AM
findcontrol in a headertemplate of datagrid S_Dogra ASP.NET 1.0 and 1.1 Basics 0 December 28th, 2006 02:52 AM
VS2005 DataGridViewComboBoxColumn databound CloudDust Visual Basic 2005 Basics 4 October 12th, 2006 06:29 PM



All times are GMT -4. The time now is 03:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.