473,721 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to put a list of items with hyperlinks under a label ?

I am new to ASP.Net. I use VB.NET as the language and Visual Studio
..NET 2003.
On my WebForm I have a label called "Categories ".
I would like to read all the categories from the database and placed
them under the label "Categories ". I also would like each category to
be a hyperlink to go to another page.
How can I do that ?
Using the codes below the categories are not placed under the label
"Categories ", and there is no hyperlink for each item.
Thank you very much.

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL
drSQL = .ExecuteReader( )
End With
If drSQL.HasRows Then
Do While drSQL.Read
Response.Write( drSQL.Item("Cat egories") & "<br>")
Loop
End If

Sep 9 '06 #1
8 1484
I can use Response.write like in the following codes, but is there a
better way to do it ?
Thanks.

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand
Dim iCnt As Integer
Dim lID As Long

sSQL = "GetCategor ies 0"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL
drSQL = .ExecuteReader( )
End With
If drSQL.HasRows Then
iCnt = 0
Do While drSQL.Read
iCnt += 1
lID = drSQL.Item("Cat ID")
Response.Write( "<a id=HyperLink" & lID & _
" href=CategoryDe tails.aspx?ID=" & lID & _
" style='Z-INDEX: 102; LEFT: 11px; POSITION: absolute;
TOP: " & (iCnt * 30) & "px'" & _
">" & drSQL.Item("Cat egories") & "</a>")
Loop
End If

Sep 9 '06 #2
Feifie,

You could use a databind for this (new in asp.net 2.0, if you're in 1.x
land... maybe a repeater?):

<asp:GridView
ID="CategoryGri d" runat="server"
DataKeyNames="C ategory"
AutoGenerateCol umns="False"
GridLines="None "
>
<Columns>
<asp:HyperLinkF ield
DataTextField=" Categories"
HeaderText="Cat egories"
DataNavigateUrl Fields="Categor ies"
DataNavigateUrl FormatString="M yPage.aspx?Cate gory={0}" />
</Columns>
</asp:GridView>

in the code behind set the DataSource to your reader:

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL

CategoryGrid.Da taSource = .ExecuteReader( )

End With
Hope that helps.

Rob MacFadyen
<fi**********@g mail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
>I am new to ASP.Net. I use VB.NET as the language and Visual Studio
.NET 2003.
On my WebForm I have a label called "Categories ".
I would like to read all the categories from the database and placed
them under the label "Categories ". I also would like each category to
be a hyperlink to go to another page.
How can I do that ?
Using the codes below the categories are not placed under the label
"Categories ", and there is no hyperlink for each item.
Thank you very much.

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL
drSQL = .ExecuteReader( )
End With
If drSQL.HasRows Then
Do While drSQL.Read
Response.Write( drSQL.Item("Cat egories") & "<br>")
Loop
End If

Sep 9 '06 #3
Thank you.
If I install .NET Framework 2.0, can I use that with Visual Studio .NET
2003, or do I need to use Visual Studio .NET 2005 ?
Thanks.

Rob MacFadyen wrote:
Feifie,

You could use a databind for this (new in asp.net 2.0, if you're in 1.x
land... maybe a repeater?):

<asp:GridView
ID="CategoryGri d" runat="server"
DataKeyNames="C ategory"
AutoGenerateCol umns="False"
GridLines="None "
>
<Columns>
<asp:HyperLinkF ield
DataTextField=" Categories"
HeaderText="Cat egories"
DataNavigateUrl Fields="Categor ies"
DataNavigateUrl FormatString="M yPage.aspx?Cate gory={0}" />
</Columns>
</asp:GridView>

in the code behind set the DataSource to your reader:

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL

CategoryGrid.Da taSource = .ExecuteReader( )

End With
Hope that helps.

Rob MacFadyen
<fi**********@g mail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
I am new to ASP.Net. I use VB.NET as the language and Visual Studio
.NET 2003.
On my WebForm I have a label called "Categories ".
I would like to read all the categories from the database and placed
them under the label "Categories ". I also would like each category to
be a hyperlink to go to another page.
How can I do that ?
Using the codes below the categories are not placed under the label
"Categories ", and there is no hyperlink for each item.
Thank you very much.

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL
drSQL = .ExecuteReader( )
End With
If drSQL.HasRows Then
Do While drSQL.Read
Response.Write( drSQL.Item("Cat egories") & "<br>")
Loop
End If
Sep 9 '06 #4
Thank you.
I am currently using .NET Framework 1.1 with Visual Studio .NET 2003.
Is there a way to it in .NET 1.1 ?

If I install .NET Framework 2.0, can I use that with Visual Studio .NET
2003, or do I need to use Visual Studio .NET 2005 ?
Thanks.

Rob MacFadyen wrote:
Feifie,

You could use a databind for this (new in asp.net 2.0, if you're in 1.x
land... maybe a repeater?):

<asp:GridView
ID="CategoryGri d" runat="server"
DataKeyNames="C ategory"
AutoGenerateCol umns="False"
GridLines="None "
>
<Columns>
<asp:HyperLinkF ield
DataTextField=" Categories"
HeaderText="Cat egories"
DataNavigateUrl Fields="Categor ies"
DataNavigateUrl FormatString="M yPage.aspx?Cate gory={0}" />
</Columns>
</asp:GridView>

in the code behind set the DataSource to your reader:

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL

CategoryGrid.Da taSource = .ExecuteReader( )

End With
Hope that helps.

Rob MacFadyen
<fi**********@g mail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
I am new to ASP.Net. I use VB.NET as the language and Visual Studio
.NET 2003.
On my WebForm I have a label called "Categories ".
I would like to read all the categories from the database and placed
them under the label "Categories ". I also would like each category to
be a hyperlink to go to another page.
How can I do that ?
Using the codes below the categories are not placed under the label
"Categories ", and there is no hyperlink for each item.
Thank you very much.

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL
drSQL = .ExecuteReader( )
End With
If drSQL.HasRows Then
Do While drSQL.Read
Response.Write( drSQL.Item("Cat egories") & "<br>")
Loop
End If
Sep 9 '06 #5
FeiFie,

I don't think so.

I dithered a long time with asp.net 1.0/1.1 and really only started diving
into things with 2.0. Let me tell you it was well worth the wait. It is much
much much better that 1.0/1.1. The advanced databinding with the new
gridview alone are worth the price. So... I'd recommend upgrading :)

Or... look into using databinding with a DataGrid or Repeater. You should be
able to do something similar with the 1.0 controls.

Rob
<fi**********@g mail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Thank you.
I am currently using .NET Framework 1.1 with Visual Studio .NET 2003.
Is there a way to it in .NET 1.1 ?

If I install .NET Framework 2.0, can I use that with Visual Studio .NET
2003, or do I need to use Visual Studio .NET 2005 ?
Thanks.

Rob MacFadyen wrote:
>Feifie,

You could use a databind for this (new in asp.net 2.0, if you're in 1.x
land... maybe a repeater?):

<asp:GridVie w
ID="CategoryGri d" runat="server"
DataKeyNames="C ategory"
AutoGenerateCol umns="False"
GridLines="None "
> >
<Columns>
<asp:HyperLinkF ield
DataTextField=" Categories"
HeaderText="Cat egories"
DataNavigateUrl Fields="Categor ies"
DataNavigateUrl FormatString="M yPage.aspx?Cate gory={0}" />
</Columns>
</asp:GridView>

in the code behind set the DataSource to your reader:

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL

CategoryGrid.Da taSource = .ExecuteReader( )

End With
Hope that helps.

Rob MacFadyen
<fi**********@ gmail.comwrote in message
news:11******* **************@ i42g2000cwa.goo glegroups.com.. .
>I am new to ASP.Net. I use VB.NET as the language and Visual Studio
.NET 2003.
On my WebForm I have a label called "Categories ".
I would like to read all the categories from the database and placed
them under the label "Categories ". I also would like each category to
be a hyperlink to go to another page.
How can I do that ?
Using the codes below the categories are not placed under the label
"Categories ", and there is no hyperlink for each item.
Thank you very much.

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL
drSQL = .ExecuteReader( )
End With
If drSQL.HasRows Then
Do While drSQL.Read
Response.Write( drSQL.Item("Cat egories") & "<br>")
Loop
End If

Sep 10 '06 #6
fi**********@gm ail.com napisał(a):
I can use Response.write like in the following codes, but is there a
better way to do it ?
Try to think of what you want to do: put _list_ of categories to
webpage,right?
So use markup to create list:
<ul>
<li><a href="..." title="...">cat egoryname</a></li>
....
</ul>

Then assign to this list a set of css rules to make it look like you
wanted. (check http://css.maxdesign.com.au for examples what you can
achieve with css and lists)

It's better way than making it only with hyperlinks and br's. You can
change category list presentation without modification in html.

--
PP
Sep 10 '06 #7
Thanks.
I just want to make sure, so to use .NET 2.0 I need Visual Studio 2005,
is that correct ?

Thanks.
Rob MacFadyen wrote:
FeiFie,

I don't think so.

I dithered a long time with asp.net 1.0/1.1 and really only started diving
into things with 2.0. Let me tell you it was well worth the wait. It is much
much much better that 1.0/1.1. The advanced databinding with the new
gridview alone are worth the price. So... I'd recommend upgrading :)

Or... look into using databinding with a DataGrid or Repeater. You should be
able to do something similar with the 1.0 controls.

Rob
<fi**********@g mail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Thank you.
I am currently using .NET Framework 1.1 with Visual Studio .NET 2003.
Is there a way to it in .NET 1.1 ?

If I install .NET Framework 2.0, can I use that with Visual Studio .NET
2003, or do I need to use Visual Studio .NET 2005 ?
Thanks.

Rob MacFadyen wrote:
Feifie,

You could use a databind for this (new in asp.net 2.0, if you're in 1.x
land... maybe a repeater?):

<asp:GridView
ID="CategoryGri d" runat="server"
DataKeyNames="C ategory"
AutoGenerateCol umns="False"
GridLines="None "
>
<Columns>
<asp:HyperLinkF ield
DataTextField=" Categories"
HeaderText="Cat egories"
DataNavigateUrl Fields="Categor ies"
DataNavigateUrl FormatString="M yPage.aspx?Cate gory={0}" />
</Columns>
</asp:GridView>

in the code behind set the DataSource to your reader:

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL

CategoryGrid.Da taSource = .ExecuteReader( )

End With
Hope that helps.

Rob MacFadyen
<fi**********@g mail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
I am new to ASP.Net. I use VB.NET as the language and Visual Studio
.NET 2003.
On my WebForm I have a label called "Categories ".
I would like to read all the categories from the database and placed
them under the label "Categories ". I also would like each category to
be a hyperlink to go to another page.
How can I do that ?
Using the codes below the categories are not placed under the label
"Categories ", and there is no hyperlink for each item.
Thank you very much.

Dim sSQL As String
Dim drSQL As SqlClient.SqlDa taReader
Dim cmdSQL As New SqlClient.SqlCo mmand()

sSQL = "GetCategor ies"
With cmdSQL
.Connection = g_Connection
.CommandText = sSQL
drSQL = .ExecuteReader( )
End With
If drSQL.HasRows Then
Do While drSQL.Read
Response.Write( drSQL.Item("Cat egories") & "<br>")
Loop
End If
Sep 10 '06 #8
<fi**********@g mail.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Thanks.
I just want to make sure, so to use .NET 2.0 I need Visual Studio 2005,
is that correct ?

Thanks.
Yes... and no.

If you installed the .NET framework 2.0 redistributable you could program
ASP.NET 2.0 just using notepad. Not fun but very doable.

If you install the ASP.NET Express edition (free version) you can use the
new Visual Studio to do ASP.NET 2.0.

I doubt if VS2003 can be configured to work with the 2.0 framework. It would
require a whole bunch of investigation and settings tweaking... if
successful you still wont get any of the new IDE features... just compiling.
So... not really worth spending a day on and potentially messing up your
current development environment.

So... from a practical standpoint.... VS2005 = .NET 2.0. Worth the money...
but there are other implications (moving from 1.x to 2.0 is easy enough...
but it is not just a recompile... some code changes may be required).

Regards,

Rob
Sep 12 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1820
by: Steven Bethard | last post by:
So, I have a list of lists, where the items in each sublist are of basically the same form. It looks something like: py> data = , .... .... , .... .... ] Now, I'd like to sample down the number of items in each sublist in the
3
26331
by: Stephen Adam | last post by:
Hi there, I'm sure i'm missing something really simple here, all i want to do is get the value of the selected item in a list box. Even after much fiddling about last night I still could not get my code to work. Below is some code which highlights my problem. All I want to do is set the lable control's text property to the value of the selected drop down list value - in this example i've shown the three ways i've tried. Please help!
5
4228
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
2
1258
by: Brian | last post by:
I am very new to VB.NET and I just need some help in a listbox matter. I don't need suggestions on how to make the overall code better. I will get there. I want to move an item from one list box to another should it be selected in combination with a button click and selected. I've got the code in there but it just wont work. Below is the entire code but I only need help with the following items: getBtn
2
2572
by: Tony Tone | last post by:
Hey Guys, I am trying to create a DropDownList with Hyperlinks as ListItem. I am creating a web page with ASP.NET and VB Any suggestions or Solutions to my problem?
0
1285
by: BigAde | last post by:
I'm having problems with the DDL in the datalist below when adding an item. The list binds properly and lists the correct values (up to about 350). The code successfully finds a ddl and loads the value into the sortedlist & the datalist. However, the selected index returned does not (always) match that shown on the web page. The first few items are
2
9958
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
5
1940
by: dmj07 | last post by:
Hi all, I would like to know a way to add a label to an update panel by using a drop down list selected item. For example: There is a list of items in a drop down list, the user selects one then presses the add button next to it and it creates a label in a table next to it. Here is the code I have at the moment:
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.