Repeater control

G

Guest

Hi Guys, I have a repeater control bound to a sqldataadapter. I have some
rows which are quite large therefore wrapping on to second line. I want to
substring the values on itemdatabound before displayed to user. Can this be
done? or is there any better way to do it.

Here is my code:
<asp:Repeater id="evtRpeater" runat="server"
OnItemDataBound="evt_ItemDataBound">
<HeaderTemplate>
<Table width="100%" style="font: 8pt verdana">
<tr style="background-color:#718db6">
<th>
Events
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color:eeeeee" height="20px">
<td>
<%# DataBinder.Eval(Container.DataItem, "event_title") %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr bgcolor="#ffffff">
<td> </td>
</tr>
<tr bgcolor="#ffffff" align="right">
<td>Click here to access Event Calendar</td>
</tr>
</TABLE>
</FooterTemplate> </asp:Repeater>
</TD>


Sub evt_ItemDataBound(ByVal Sender As Object, ByVal e As
RepeaterItemEventArgs)

' This event is raised for the header, the footer, separators, and
items.

' Execute the following logic for Items and Alternating Items.
If (Convert.ToString(e.Item).Length > 25) Then
e.Item.DataItem = Convert.ToString(e.Item).Substring(0, 25)
End If

Thanks

Manny
 
J

Joe Fallon

I use ItemDataBound a lot.
It is an extremely useful event.
Sounds like it works fine for you too!
 
G

Guest

no Joe, i was asking question in that snippet. Anyway i got it done
alternately by passing the value through function such as <%#FunctionA(
DataBinder.Eval(Container.DataItem, "event_title")) %>

and then writing the string function in Codebehind
It sure was fun to get this done.

Manny
 

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

Top