Problems with dynamic links in Datalist

M

mister-Ed

I am displaying subcategories in my datalist, and now I have a
bizarre thing happen when I add a new subcategory record in my sql
database, the new subcategory link does not click into the next page:

Here is the code surrounding my dynamic 'subcategory':

<a href="prov-results1.aspx?county=<
%#Server.UrlEncode(Request.QueryString("county")) & "&subcat=" &
Server.UrlEncode((Eval("SubCategory").ToString())) & "&category=" &
Server.UrlEncode((Eval("Category").ToString())) & "&uregion=" &
Server.UrlEncode((Eval("uregion").ToString()))%>"><%#
Eval("SubCategory")%></a>

In the page source code , the subcategory that works has + signs
after the Category value. I have used
Server.UrlEncode((Eval("Category").ToString().trim())) to eliminate
these erroneous + signs, but that disables ALL the links from
working :

<a href="prov-results1.aspx?
county=Clark&subcat=Asbestos&category=Attorneys++++++++++++++++++++++++
++&uregion=lv">Asbestos</a>

The subcategory that I have just added to the database doesnt work
when trying to click:

<a href="prov-results1.aspx?
county=Clark&subcat=CriminalLaw&category=Attorneys&uregion=">CriminalLaw</
a>


....i've used NavigateURL in the datalist in the past, but with
problems

??
Ed
 
N

Nathan Sokalski

Something that I might recommend (it may not explain your problem) would be
to, first of all, use the ASP.NET HyperLink control instead. I might also
suggest that because you have so many inline functions that you use the
ItemDataBound event, the String.Format method, and assign the results to the
NavigateUrl property. Also, I believe that when inside the <%# %> tags, you
need to use + instead of &. Also, did you try doing a View Source of the
output for your current code? This can sometimes help you figure out exactly
what part is not working. Good Luck!
 

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,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top