0

Please help I am trying to add a condition in repeater, the code I am using is not working. Please have a look and provide me solution, here is my code

<asp:Repeater ID="myID" runat="server" onitemcommand="rptjobs_ItemCommand1">
      <ItemTemplate>
          <div class="row custom_bdrbtm">
        <div class="col-md-9 custom_bdrrgt"><asp:Label ID="lbljobTitle1"    runat="server" Text='<%# Eval("JobTitle")%>'></asp:Label>
            <%# Eval("Description").ToString().Length >150%> ? <p> <%# Eval("Description").ToString().Substring(0,150)%> .....</p> : <%# Eval("Description").ToString()%></div>

              </div>

      </ItemTemplate>
      </asp:Repeater>

I hope I have explained my problem Thanks!

Deepika Thakur
  • 173
  • 3
  • 11
  • 2
    Not working how? Simply saying not working is like going to the doctor and saying you don't feel well and expecting a diagnosis.... – Tim Jan 27 '16 at 04:59
  • Your conditional check is outside of the server side code, The Question Mark/Colon notation needs to be within the <%# %> tags. It's possible to do conditionally formatting this way, but after a while it's gets messy :) – Phill Jan 27 '16 at 07:44

1 Answers1

0

You are trying to do an if else based on the data, if I understood this correctly. In which case I think you should be doing this while the data is being bound to the control.

This SO Post discusses handling the onDataItemBound of the repeater.

I tried posting this as a comment, but I dont have enough reputation to post a comment and hence I have posted this as an answer

Community
  • 1
  • 1
Kumar C
  • 100
  • 2
  • 13