How can I display only part of data in the repeater control column?

ASPNet_Developer
ASPNet_Developer used Ask the Experts™
on
I have repeater control which I am binding directly to my datatable, to display data in column.
-----------------------------
ASPX page
----------------------------------
<asp:Repeater ID="Repeater1" runat="server">
      <HeaderTemplate>
      <table>
      <tr>
      <td>NAME</td>
      <td>DESCRIPTION</td>
      </tr>      
      </HeaderTemplate>
      <ItemTemplate>
      <tr>
      <td>
      <%# DataBinder.Eval(Container.DataItem, "NAME")%>
      </td>
      </tr>      
      <tr>
      <td>
      <%# DataBinder.Eval(Container.DataItem, "DESCRIPTION")%>
      </td>
      </tr>      
      </ItemTemplate>
      <AlternatingItemTemplate>
      <tr>
      <td>
      <%# DataBinder.Eval(Container.DataItem, "NAME")%>
      </td>
      </tr>      
      <tr>
      <td>
      <%# DataBinder.Eval(Container.DataItem, "DESCRIPTION")%>
      </td>
      </tr>      
      </AlternatingItemTemplate>
      <FooterTemplate>
      </table>
      </FooterTemplate>
      </asp:Repeater>
----------------------------------
ASPX.VB page
-------------------------------------
If ds.Tables(0).Rows.Count > 0 Then
      Repeater1.DataSource = ds
Repeater1.DataBind()
            End If
            myDS.Dispose()
----------------------------------------
In DESCRIPTION the data is really long. Ex:'1-1-1-this is example-123456-d-d.................'.
I do not want to display all of it.
Is there a way I can display only "this is example-123456" when I bind the column to the repeater?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Yes, in the repeater's itemdatabound event, use string.trim to remove part of [description].

Commented:
instead of <%# DataBinder.Eval(Container.DataItem, "DESCRIPTION")%>, use an asp:label

and in itemdataboud event, use e.Findcontrol("thatlabelID"), and set its text to wat ever u want
Most Valuable Expert 2012
Top Expert 2014
Commented:
You can change this

 <%# DataBinder.Eval(Container.DataItem, "DESCRIPTION")%>

to

 <%# IIF(DataBinder.Eval(Container.DataItem, "Description").Length > 20, DataBinder.Eval(Container.DataItem, "DESCRIPTION").Substring(0, 20), DataBinder.Eval(Container.DataItem, "DESCRIPTION"))%>

Author

Commented:
Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial