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

asp:hyperlink object in Repeater control ??

P: n/a
Having some problems getting a hyperlink object to work in my repeater
control, It displays the text I have asked it to for the hyperlink, but it
does not act as a link. My repeater code is below but here is the snippet of
my asp:hyperlink object;

<asp:HyperLink
NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(C onta
iner.DataItem,"CLIENTREF")%>
ID="Hyperlink1"><%#DataBinder.Eval(Container.DataI tem,
"NAME")%></asp:HyperLink>

If anyone can help I would be much appreciative. The field clientref by the
way is stored as a guid in ms sql datastore.

<asp:repeater id="statsRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td colspan="2" class="tableLightBlue">
<asp:HyperLink
NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(C onta
iner.DataItem,"CLIENTREF")%>
ID="Hyperlink1"><%#DataBinder.Eval(Container.DataI tem,
"NAME")%></asp:HyperLink>
</td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last Successful Inbound</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"LASTSUCCESSFULINBOUND")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last IP Connection
Attempt</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"LASTIPCONNECTATTEMPT")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last IP Successful
Disconnection</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"LASTIPSUCCESSFULDISCONNECT")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">First IP Failure</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"FIRSTIPFAILURE")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Next IP Retry</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"NEXTIPRETRY")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Martin,

You for to use runat="server" so it wasn't executing on the server. I also
found a couple of syntax errors. My version is below.

Does this help?

Ken
Microsoft MVP [ASP.NET]

<asp:repeater id="statsRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td colspan="2" class="tableLightBlue">
<asp:HyperLink Runat=server
NavigateUrl='authonly/clientdetails.aspx?searchID=<%#DataBinder.Eval(Con tainer.DataItem,"CLIENTREF")%>'
ID="Hyperlink1">
<%#DataBinder.Eval(Container.DataItem,"NAME")%>
</asp:HyperLink>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>

"Martin Dew" <re************************@adastra.co.uk> wrote in message
news:Of**************@TK2MSFTNGP12.phx.gbl...
Having some problems getting a hyperlink object to work in my repeater
control, It displays the text I have asked it to for the hyperlink, but it
does not act as a link. My repeater code is below but here is the snippet
of
my asp:hyperlink object;

<asp:HyperLink
NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(C onta
iner.DataItem,"CLIENTREF")%>
ID="Hyperlink1"><%#DataBinder.Eval(Container.DataI tem,
"NAME")%></asp:HyperLink>

If anyone can help I would be much appreciative. The field clientref by
the
way is stored as a guid in ms sql datastore.

<asp:repeater id="statsRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td colspan="2" class="tableLightBlue">
<asp:HyperLink
NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(C onta
iner.DataItem,"CLIENTREF")%>
ID="Hyperlink1"><%#DataBinder.Eval(Container.DataI tem,
"NAME")%></asp:HyperLink>
</td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last Successful
Inbound</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"LASTSUCCESSFULINBOUND")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last IP Connection
Attempt</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"LASTIPCONNECTATTEMPT")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last IP Successful
Disconnection</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"LASTIPSUCCESSFULDISCONNECT")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">First IP Failure</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"FIRSTIPFAILURE")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Next IP Retry</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"NEXTIPRETRY")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>


Nov 18 '05 #2

P: n/a
Hi Martin,

You forgot to use runat="server" so it wasn't executing on the server. I
also
found a couple of syntax errors. My version is below.

Does this help?

Ken
Microsoft MVP [ASP.NET]

<asp:repeater id="statsRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td colspan="2" class="tableLightBlue">
<asp:HyperLink Runat=server
NavigateUrl='authonly/clientdetails.aspx?searchID=<%#DataBinder.Eval(Con tainer.DataItem,"CLIENTREF")%>'
ID="Hyperlink1">
<%#DataBinder.Eval(Container.DataItem,"NAME")%>
</asp:HyperLink>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>

"Martin Dew" <re************************@adastra.co.uk> wrote in message
news:Of**************@TK2MSFTNGP12.phx.gbl...
Having some problems getting a hyperlink object to work in my repeater
control, It displays the text I have asked it to for the hyperlink, but it
does not act as a link. My repeater code is below but here is the snippet
of
my asp:hyperlink object;

<asp:HyperLink
NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(C onta
iner.DataItem,"CLIENTREF")%>
ID="Hyperlink1"><%#DataBinder.Eval(Container.DataI tem,
"NAME")%></asp:HyperLink>

If anyone can help I would be much appreciative. The field clientref by
the
way is stored as a guid in ms sql datastore.

<asp:repeater id="statsRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td colspan="2" class="tableLightBlue">
<asp:HyperLink
NavigateUrl="authonly/clientdetails.aspx?searchID="+<%#DataBinder.Eval(C onta
iner.DataItem,"CLIENTREF")%>
ID="Hyperlink1"><%#DataBinder.Eval(Container.DataI tem,
"NAME")%></asp:HyperLink>
</td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last Successful
Inbound</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"LASTSUCCESSFULINBOUND")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last IP Connection
Attempt</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"LASTIPCONNECTATTEMPT")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last IP Successful
Disconnection</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"LASTIPSUCCESSFULDISCONNECT")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">First IP Failure</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"FIRSTIPFAILURE")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Next IP Retry</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(C ontainer.DataItem,
"NEXTIPRETRY")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>


Nov 18 '05 #3

P: n/a
thanks Ken. However it does make this hyperlink actually act as a hyperlink,
it does not take the databound value and add it to the Navigate URL string.

when you hover over the link it simply tries to navigate to
//authonly/clientdetails.aspx?searchID=<%#DataBinder.Eval(Con tainer.DataItem
,"CLIENTREF")%>

instead of replacing the
<%#DataBinder.Eval(Container.DataItem,"CLIENTREF") %> with the value of its
databoudn field.

any advice ?
Nov 18 '05 #4

P: n/a
Hi Martin,

Oops. Sorry about that. Not sure what's going on but there's another way to
skin this cat... use a helper function:

Function MakeURL(ByVal strURL As String) As String
Return "clientdetails.aspx?searchID=" & strURL
End Function

<asp:HyperLink Runat=server NavigateUrl='<%#
MakeURL(DataBinder.Eval(Container.DataItem,"CLIENT REF"))%>' ID="Hyperlink1">

My test code is below.

Does *this* help? <grin>

Ken
Toronto
<asp:repeater id="statsRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td colspan="2" class="tableLightBlue">
<asp:HyperLink Runat=server NavigateUrl='<%#
MakeURL(DataBinder.Eval(Container.DataItem,"CLIENT REF"))%>' ID="Hyperlink1">
<%#DataBinder.Eval(Container.DataItem,"NAME")%>
</asp:HyperLink>
<asp:HyperLink id="Hyperlink2" runat="server" NavigateUrl="asas.aspx"
ImageUrl="dfdf.aspx">HyperLink</asp:HyperLink></P>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
statsRepeater.DataSource = _
CreateDataSource()
statsRepeater.DataBind()
End Sub

Function MakeURL(ByVal strURL As String) As String
Return "clientdetails.aspx?searchID=" & strURL
End Function

Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("Name", GetType(String)))
dt.Columns.Add(New DataColumn _
("CLIENTREF", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = "ABCD-EFGH" & i.ToString
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource
"Martin Dew" <re************************@adastra.co.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
thanks Ken. However it does make this hyperlink actually act as a
hyperlink,
it does not take the databound value and add it to the Navigate URL
string.

when you hover over the link it simply tries to navigate to
//authonly/clientdetails.aspx?searchID=<%#DataBinder.Eval(Con tainer.DataItem
,"CLIENTREF")%>

instead of replacing the
<%#DataBinder.Eval(Container.DataItem,"CLIENTREF") %> with the value of its
databoudn field.

any advice ?


Nov 18 '05 #5

P: n/a
Ken, thanks for your help on this.

I am writing this in c#, so I have added to my code page

public string MakeURL(string strGuid)
{
return string.Format("authonly/clientdetails.aspx?searchID={0}",strGuid);
}

and in my html view I now have this ;

<asp:HyperLink Runat=server
NavigateUrl='<%#MakeURL(DataBinder.Eval(Container. DataItem,"CLIENTREF"))%>'
ID="Hyperlink2">
<%#DataBinder.Eval(Container.DataItem,"NAME")%>
</asp:HyperLink>

but when the page tries to load I get the following compilation error ;

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS1502: The best overloaded method match for
'Concentrator.index.MakeURL(string)' has some invalid arguments

Source Error:

Line 87: <tr>
Line 88: <td colspan="2" class="tableLightBlue">
Line 89: <asp:HyperLink Runat=server
Line 90:
NavigateUrl='<%#MakeURL(DataBinder.Eval(Container. DataItem,"NAME"))%>'
Line 91: ID="Hyperlink2">
Source File: http://localhost/Concentrator/index.aspx Line: 89

I expect I am doing something really stupid..

Regards

Martin

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

Oops. Sorry about that. Not sure what's going on but there's another way to skin this cat... use a helper function:

Function MakeURL(ByVal strURL As String) As String
Return "clientdetails.aspx?searchID=" & strURL
End Function

<asp:HyperLink Runat=server NavigateUrl='<%#
MakeURL(DataBinder.Eval(Container.DataItem,"CLIENT REF"))%>' ID="Hyperlink1">
My test code is below.

Does *this* help? <grin>

Ken
Toronto
<asp:repeater id="statsRepeater" runat="server">
<HeaderTemplate>
<table border="0" width="100%" cellspacing="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td colspan="2" class="tableLightBlue">
<asp:HyperLink Runat=server NavigateUrl='<%#
MakeURL(DataBinder.Eval(Container.DataItem,"CLIENT REF"))%>' ID="Hyperlink1"> <%#DataBinder.Eval(Container.DataItem,"NAME")%>
</asp:HyperLink>
<asp:HyperLink id="Hyperlink2" runat="server" NavigateUrl="asas.aspx" ImageUrl="dfdf.aspx">HyperLink</asp:HyperLink></P>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
statsRepeater.DataSource = _
CreateDataSource()
statsRepeater.DataBind()
End Sub

Function MakeURL(ByVal strURL As String) As String
Return "clientdetails.aspx?searchID=" & strURL
End Function

Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("Name", GetType(String)))
dt.Columns.Add(New DataColumn _
("CLIENTREF", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = "ABCD-EFGH" & i.ToString
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource
"Martin Dew" <re************************@adastra.co.uk> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
thanks Ken. However it does make this hyperlink actually act as a
hyperlink,
it does not take the databound value and add it to the Navigate URL
string.

when you hover over the link it simply tries to navigate to
//authonly/clientdetails.aspx?searchID=<%#DataBinder.Eval(Con tainer.DataItem ,"CLIENTREF")%>

instead of replacing the
<%#DataBinder.Eval(Container.DataItem,"CLIENTREF") %> with the value of its databoudn field.

any advice ?

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.