Hi all,
Try this example to Change FontSize with Gridview According to Condition
add this CSS Style in your page
<style type="text/css">
.Small
{
font-size: small;
}
.Large
{
font-size: large;
}
</style>In Gridview ItemTemplate
<asp:TemplateField HeaderText="Description" SortExpression="Description">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>' CssClass='<%# (Convert.ToString(Eval("Description")).Length > 30)? "Small": "Large"%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>and there is another way to do the same
<asp:TemplateField HeaderText="Description" SortExpression="Description">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>' Font-Size='<%# (Eval("Description").ToString().Length > 30) ? FontUnit.XSmall : FontUnit.Small %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>Sharing is Caring,Danish Kharadi.
No comments:
Post a Comment