asp:hyperlink object in Repeater control ??

M

Martin Dew

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(Conta
iner.DataItem,"CLIENTREF")%>
ID="Hyperlink1"><%#DataBinder.Eval(Container.DataItem,
"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(Conta
iner.DataItem,"CLIENTREF")%>
ID="Hyperlink1"><%#DataBinder.Eval(Container.DataItem,
"NAME")%></asp:HyperLink>
</td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last Successful Inbound</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(Container.DataItem,
"LASTSUCCESSFULINBOUND")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last IP Connection
Attempt</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(Container.DataItem,
"LASTIPCONNECTATTEMPT")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Last IP Successful
Disconnection</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(Container.DataItem,
"LASTIPSUCCESSFULDISCONNECT")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">First IP Failure</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(Container.DataItem,
"FIRSTIPFAILURE")%></td>
</tr>
<tr>
<td width="60%" class="tableFailureBodyWhite">Next IP Retry</td>
<td width="40%"
class="tableFailureBodyWhite"><%#DataBinder.Eval(Container.DataItem,
"NEXTIPRETRY")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>
 
K

Ken Cox [Microsoft MVP]

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(Container.DataItem,"CLIENTREF")%>'
ID="Hyperlink1">
<%#DataBinder.Eval(Container.DataItem,"NAME")%>
</asp:HyperLink>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>
 
K

Ken Cox [Microsoft MVP]

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(Container.DataItem,"CLIENTREF")%>'
ID="Hyperlink1">
<%#DataBinder.Eval(Container.DataItem,"NAME")%>
</asp:HyperLink>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>
 
M

Martin Dew

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(Container.DataItem
,"CLIENTREF")%>

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

any advice ?
 
M

Martin Dew

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top