473,395 Members | 1,558 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,395 software developers and data experts.

Asp Hyperlink and Datalist Question

What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks.

<asp:datalist id="DataList1" runat="server"
RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink
id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx/ConsultantId=1&DisplayId={0})",
Container.DataItem("ID"))%>' runat="server" /><BR>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</ItemTemplate>
</asp:datalist>

Nov 19 '05 #1
9 2697
Hi Leon,

You had some syntax errors. When I fix those, it runs. Not sure what it is
supposed to look like though. See the code below.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto

<asp:datalist id="DataList1" runat="server" RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx?ConsultantId=1&DisplayId={0}",
Container.DataItem("ID"))%>' runat="server" /><BR>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</ItemTemplate>
</asp:datalist>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
DataList1.DataSource = CreateDataSource()
DataList1.DataBind()
End If
End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("ID", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("PathToDisplyPic", GetType(String)))
Dim i As Integer
For i = 0 To 4
dr = dt.NewRow()
dr(0) = i
dr(1) = "path" + i.ToString()
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

"Leon" <vn*****@msn.com> wrote in message
news:ew**************@TK2MSFTNGP14.phx.gbl...
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks.

<asp:datalist id="DataList1" runat="server"
RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink
id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx/ConsultantId=1&DisplayId={0})",
Container.DataItem("ID"))%>' runat="server" /><BR>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</ItemTemplate>
</asp:datalist>

Nov 19 '05 #2
Thanks everything works fine now, but...
How do I separate each pair of Hyperlink & Label with a space horizontal?

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Leon,

You had some syntax errors. When I fix those, it runs. Not sure what it is
supposed to look like though. See the code below.

Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto

<asp:datalist id="DataList1" runat="server" RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx?ConsultantId=1&DisplayId={0}",
Container.DataItem("ID"))%>' runat="server" /><BR>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</ItemTemplate>
</asp:datalist>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
DataList1.DataSource = CreateDataSource()
DataList1.DataBind()
End If
End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("ID", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("PathToDisplyPic", GetType(String)))
Dim i As Integer
For i = 0 To 4
dr = dt.NewRow()
dr(0) = i
dr(1) = "path" + i.ToString()
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

"Leon" <vn*****@msn.com> wrote in message
news:ew**************@TK2MSFTNGP14.phx.gbl...
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks.

<asp:datalist id="DataList1" runat="server"
RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink
id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx/ConsultantId=1&DisplayId={0})",
Container.DataItem("ID"))%>' runat="server" /><BR>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</ItemTemplate>
</asp:datalist>


Nov 19 '05 #3

"Leon" <vn*****@msn.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
Thanks everything works fine now, but...
How do I separate each pair of Hyperlink & Label with a space horizontal?


Sorry, I'm not sure what you mean. Could you show me what it should look
like in regular HTML? You currently have four columns. There's a label below
each link. Perhaps you can clarify?

Thanks,

Ken
Nov 19 '05 #4
This is what it should look like..

Hyperlink -Space- Hyperlink -Space- Hyperlink -Space- Hyperlink
Label Label Label
Label
|Space
Hyperlink Hyperlink Hyperlink
Hyperlink
Label -Space- Label -Space- Label -Space-
Label
ECT....

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:uc**************@TK2MSFTNGP14.phx.gbl...

"Leon" <vn*****@msn.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
Thanks everything works fine now, but...
How do I separate each pair of Hyperlink & Label with a space horizontal?


Sorry, I'm not sure what you mean. Could you show me what it should look
like in regular HTML? You currently have four columns. There's a label
below each link. Perhaps you can clarify?

Thanks,

Ken

Nov 19 '05 #5
Hi Leon,

You could throw in some non-breaking spaces to do that.

<asp:datalist id="DataList1" runat="server" RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx?ConsultantId=1&DisplayId={0}",
Container.DataItem("ID"))%>' runat="server"
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;< BR>
<asp:Label id="Label1" runat="server">Label</asp:Label><br />
</ItemTemplate>
</asp:datalist>

"Leon" <vn*****@msn.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
This is what it should look like..

Hyperlink -Space- Hyperlink -Space- Hyperlink -Space-
Hyperlink
Label Label Label Label
|Space
Hyperlink Hyperlink Hyperlink Hyperlink
Label -Space- Label -Space- Label -Space-
Label
ECT....

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:uc**************@TK2MSFTNGP14.phx.gbl...

"Leon" <vn*****@msn.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
Thanks everything works fine now, but...
How do I separate each pair of Hyperlink & Label with a space
horizontal?


Sorry, I'm not sure what you mean. Could you show me what it should look
like in regular HTML? You currently have four columns. There's a label
below each link. Perhaps you can clarify?

Thanks,

Ken


Nov 19 '05 #6
Thanks, but would it be best for me to put the
itemtemplate info in a html table <tr>.

Thanks again Ken!

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:uG*************@TK2MSFTNGP14.phx.gbl...
Hi Leon,

You could throw in some non-breaking spaces to do that.

<asp:datalist id="DataList1" runat="server" RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx?ConsultantId=1&DisplayId={0}",
Container.DataItem("ID"))%>' runat="server"
/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;< BR>
<asp:Label id="Label1" runat="server">Label</asp:Label><br />
</ItemTemplate>
</asp:datalist>

"Leon" <vn*****@msn.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
This is what it should look like..

Hyperlink -Space- Hyperlink -Space- Hyperlink -Space- Hyperlink
Label Label Label Label
|Space
Hyperlink Hyperlink Hyperlink
Hyperlink
Label -Space- Label -Space- Label -Space-
Label
ECT....

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:uc**************@TK2MSFTNGP14.phx.gbl...

"Leon" <vn*****@msn.com> wrote in message
news:Ov**************@TK2MSFTNGP10.phx.gbl...
Thanks everything works fine now, but...
How do I separate each pair of Hyperlink & Label with a space
horizontal?

Sorry, I'm not sure what you mean. Could you show me what it should look
like in regular HTML? You currently have four columns. There's a label
below each link. Perhaps you can clarify?

Thanks,

Ken



Nov 19 '05 #7
1. Are u sure you attached a data source your datalist ?
2. HyperLink NavigateUrl "Toyota/Display.aspx/ConsultantId=1&DisplayId={0}"
is it correct? "Toyota/Display.aspx?ConsultantId=1&DisplayId={0}"
3. What is wrong ? What about output ? Can u see anything?

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Leon" <vn*****@msn.com> wrote in message
news:ew**************@TK2MSFTNGP14.phx.gbl...
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks.

<asp:datalist id="DataList1" runat="server"
RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink
id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx/ConsultantId=1&DisplayId={0})",
Container.DataItem("ID"))%>' runat="server" /><BR>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</ItemTemplate>
</asp:datalist>

Nov 19 '05 #8
I'm sure! I see the data perfect, but now I'm trying to format the
data exactly the way I want it.

"Yunus Emre ALPÖZEN [MCAD.NET]" <ye***@msakademik.net> wrote in message
news:ev**************@TK2MSFTNGP14.phx.gbl...
1. Are u sure you attached a data source your datalist ?
2. HyperLink NavigateUrl
"Toyota/Display.aspx/ConsultantId=1&DisplayId={0}" is it correct?
"Toyota/Display.aspx?ConsultantId=1&DisplayId={0}"
3. What is wrong ? What about output ? Can u see anything?

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Leon" <vn*****@msn.com> wrote in message
news:ew**************@TK2MSFTNGP14.phx.gbl...
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks.

<asp:datalist id="DataList1" runat="server"
RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink
id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx/ConsultantId=1&DisplayId={0})",
Container.DataItem("ID"))%>' runat="server" /><BR>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</ItemTemplate>
</asp:datalist>


Nov 19 '05 #9
Ok. I couldnot understand your question... Is it possible to describe your
problem briefly?

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Leon" <vn*****@msn.com> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
I'm sure! I see the data perfect, but now I'm trying to format the
data exactly the way I want it.

"Yunus Emre ALPÖZEN [MCAD.NET]" <ye***@msakademik.net> wrote in message
news:ev**************@TK2MSFTNGP14.phx.gbl...
1. Are u sure you attached a data source your datalist ?
2. HyperLink NavigateUrl
"Toyota/Display.aspx/ConsultantId=1&DisplayId={0}" is it correct?
"Toyota/Display.aspx?ConsultantId=1&DisplayId={0}"
3. What is wrong ? What about output ? Can u see anything?

--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET

"Leon" <vn*****@msn.com> wrote in message
news:ew**************@TK2MSFTNGP14.phx.gbl...
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks.

<asp:datalist id="DataList1" runat="server"
RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink
id=HyperLink1
ImageUrl= '<%# String.Format("Toyota/Images/Showroom/" &
Container.DataItem("PathToDisplyPic"))%>'
NavigateUrl='<%#
String.Format("Toyota/Display.aspx/ConsultantId=1&DisplayId={0})",
Container.DataItem("ID"))%>' runat="server" /><BR>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</ItemTemplate>
</asp:datalist>



Nov 19 '05 #10

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

Similar topics

0
by: Arjen | last post by:
Hello, Here is my datalist. <asp:DataList id="myDataList" CellPadding="4" Width="100%" runat="server"> <ItemTemplate> <span class="Normal"> <asp:HyperLink id="link" Text='<%#...
0
by: Dave | last post by:
Hi , I have the following where I need to append a string variable inside a hyperlink template, inside a datalist. The variable 'categoryList' is the culprit. No matter where this variable is...
1
by: Amil | last post by:
I have a page with a hyperlink (actually in a datalist). I want the URL to do a postback essentially. I tried to use Page.Request in the NavigateUrl, but it's always empty? How do I tell it to...
2
by: Big E | last post by:
I'm using ASP.Net and SQL Server. I have a table called states. I have 2 forms. On form 1 is the 50 states in textboxes created with a loop. I want to have those 50 or 45 or whatever amount of...
6
by: Patrick Olurotimi Ige | last post by:
I have a Datalist in a form with a hyperlink i would like to make the hyperlink visible only when a checkbox is clicked and not visible when not clicked . But doing this below in page_load it...
2
by: milbrand | last post by:
I have an ASPX page with a DataList. The ListItems contain a DropDownList and a Hyper Link. The user selects an Item from the Dropdown box and then selects the hyperlink to edit that item. My...
0
by: vidhuraj | last post by:
hi all i have a hyperlink control and image control in my datalist i have binded the values for it ie, datalist will now display some images in image control and their corresponding ID in the...
1
by: rn5a | last post by:
Consider the following code: <script runat="server"> Sub Page_Load(obj As Object, ea As EventArgs) Dim sqlReader As SqlDataReader sqlReader = 'calling a function that returns SqlDataReader ...
1
by: Andy B | last post by:
I have this code: <asp:DataList id="NewsList" runat="server"> <HeaderTemplate> News list </HeaderTemplate> <ItemTemplate> <!-- news article code goes here --> </ItemTemplate>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.