Link to home
Start Free TrialLog in
Avatar of ASPNet_Developer
ASPNet_Developer

asked on

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

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?
Avatar of Rick
Rick

Yes, in the repeater's itemdatabound event, use string.trim to remove part of [description].
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
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ASPNet_Developer

ASKER

Thanks.