By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Asp Hyperlink and Datalist Question

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
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

P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.