PDA

View Full Version : Trim Function with Item Template


davidseye
03-13-2003, 06:14 AM
I have populated a datalist from a database table and applied the results in the page with an item template. This is the code:

<ASP:DataList id="NavLinkList" runat="server">
<ItemTemplate>
<table>
<tr>
<td valign="top">
<a href="../<%# DataBinder.Eval(Container.DataItem, "navLink") %>" target="<%# DataBinder.Eval(Container.DataItem, "target") %>"><span style="font-size:8pt;color:white;text-decoration:none;"><%# DataBinder.Eval(Container.DataItem, "navText") %></span></a>
</td>
</tr>
</table>
</ItemTemplate>
</ASP:DataList>

What I need help with is this. The target value has extra white space which I would like to apply the trim function to remove, but all my attempts to now have proven futile. Can anyone suggest how I can trim this: <%# DataBinder.Eval(Container.DataItem, "target") %> ?

Or perhaps I should bind the data to a different control: a hyperlink or a repeater. What do you think?
Thanks

davidseye
03-14-2003, 02:37 AM
Thanks Bruce. I rather thought that would be the case. I appreciate you taking the time to respond.

bruce
03-14-2003, 10:08 AM
I had the same problem when i was building an application.

I spent about an hour trying to figure out host to include any code inside the <%# %>, but i couldn't find anything.

What i did instead was to construct the table programatically and populate it with values.

In your situation, you may also want to try clean the data table before you bind it to the datalist.

Hope this helps.

[b]quote:Originally posted by davidseye

I have populated a datalist from a database table and applied the results in the page with an item template. This is the code:

<ASP:DataList id="NavLinkList" runat="server">
<ItemTemplate>
<table>
<tr>
<td valign="top">
<a href="../<%# DataBinder.Eval(Container.DataItem, "navLink") %>" target="<%# DataBinder.Eval(Container.DataItem, "target") %>"><span style="font-size:8pt;color:white;text-decoration:none;"><%# DataBinder.Eval(Container.DataItem, "navText") %></span></a>
</td>
</tr>
</table>
</ItemTemplate>
</ASP:DataList>

What I need help with is this. The target value has extra white space which I would like to apply the trim function to remove, but all my attempts to now have proven futile. Can anyone suggest how I can trim this: <%# DataBinder.Eval(Container.DataItem, "target") %> ?

Or perhaps I should bind the data to a different control: a hyperlink or a repeater. What do you think?
Thanks
</blockquote id="quote"></font id="quote">