user329765
user329765

Reputation: 15

Label control in ItemTemplate tag in TemplateField tag in Gridview control

I am using a label control in ItemTemplate tag in TemplateField tag in Gridview Control to show a field of data of my database . I want if a length of data is higher than 100 charachter the label control doens't show all of data.

<ItemTemplate>
<asp:Label ID="label4" runat="server" Text='<%# Bind("Description") %>' Width="200px" Font-Names="B Nazanin" EnableTheming="false" Height="24px" BorderStyle="Dashed"></asp:Label>
</ItemTemplate>

What should I do ?

Upvotes: 1

Views: 6552

Answers (1)

Tim Schmelter
Tim Schmelter

Reputation: 460288

This is the simplest approach:

Text='<%# Eval("Description").ToString().Substring(0, 100) %>'

Upvotes: 2

Related Questions