469,299 Members | 2,069 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

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 2530
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Amil | last post: by
2 posts views Thread by Big E | last post: by
6 posts views Thread by Patrick Olurotimi Ige | last post: by
1 post views Thread by rn5a | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.