Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenation in html 2

Status
Not open for further replies.

Zarcom

Programmer
May 7, 2002
1,275
CA
I may be just overtired here but I thought this would be cool. I am making a link on a datagrid based on some static text (the page itself) and some dynamic text (the query string). I do realize the ways normally used to do this.
A select button and a redirect in the selectedindex change event.

Building the link on the item created event.
and I am sure there are others.

Just because I like to be difficult I thought of doing it this way. Use the Link Column type, add the static text in and concatenate the dynamic text on the end. However, I don't know how to do the concatenate bit in the HTML.
This is what I have so far,
<asp:HyperLinkColumn DataTextField=&quot;CampName&quot; NavigateUrl=&quot;SiteSelection.aspx?Camp=&quot; <%# DataBinder.Eval(Container, &quot;DataItem.CampName&quot;) %>></asp:HyperLinkColumn>


if anyone has suggestions such as go to bed and use a different method tomorrow I'll accept them. Thanks all. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Nobody has any suggestions on this? That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Hi Mark,

I'm assuming that this doesn't give an error, but it never gets the camp name in the querystring? If so, you probably just need to move your quotation mark to after the code-closing tag (%>).

The new line would look like this (note the quotes in red):

<asp:HyperLinkColumn DataTextField=&quot;CampName&quot; NavigateUrl=&quot;SiteSelection.aspx?Camp=<%# DataBinder.Eval(Container, &quot;DataItem.CampName&quot;) %>&quot;></asp:HyperLinkColumn>

Hope this helps. If I am misunderstanding the questions, kick me in the tail a few times to clear my head.


Kevin B.
.Net Programmer [thumbsup]
 
gah!! why don't you kick me a few times that was so simple!
In that it makes perfect sense however, I do get an error with either my old stuff or the stuff you have.
Parser Error Message: Literal content ('<asp:HyperLinkColumn DataTextField=&quot;CampName&quot; NavigateUrl=&quot;SiteSelection.aspx?Camp=') is not allowed within a 'System.Web.UI.WebControls.DataGridColumnCollection'.

That is the error I am getting I thought it might be cause of the double quotes but a double double quote which is a string quote rather than a termination doesn't help either. So I am really not sure what it is.
Any other suggestions? That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Concatenate inside your databinding expression.

NavigateUrl=&quot; <%# &quot;SiteSelection.aspx?Camp=&quot; & DataBinder.Eval(Container, &quot;DataItem.CampName&quot;) %>&quot;>
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Same error but thanks. I think I may just do this another way. Just thought this would be better if it worked.

That is unless someone has some magic code? hmm do you? That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Okay. . . turned out to be an interesting problem. However, there is a way (this I thoroughly tested it, instead of naively wishing for the moving of the quote sign to fix it).

In order to do what you want to do, you can use the following code:

<asp:HyperLinkColumn DataTextField=&quot;CampName&quot; DataNavigateUrlField=&quot;CampName&quot; DataNavigateUrlFormatString=&quot;SiteSelection.aspx?Camp={0}&quot;></asp:HyperLinkColumn>

The DataNavigateUrlField sets up the datafield to bind to the navigation URL, which is then used in the DataNavigateURLFormatString. . . by substituting {0} with the data value.

Hope this helps!


Kevin B.
.Net Programmer [thumbsup]
 
Thanks Brad.. I mean Kevin. I am definetly not on the top of my game today. The brain just doesn't feel like functioning I guess.

Thanks again nice solution That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top