Click here to Skip to main content
12,397,575 members (61,231 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
Sir i m inserting my data in database. now i am retrieving it in a gridview. everything is ok, but i want to show the data (as description of any country) in size of 200px,2oopx. but the description is too large, and it is overlapping in other cells of next country description.

My code of gridview is as.

<asp:GridView ID="gridCountry" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField>
                <HeaderTemplate>ID</HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="grdlblID" runat="server" Text='<%# Eval("_COUNTRYID") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <HeaderTemplate>Country</HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="grdlblCountry" runat="server" Text='<%# Eval("_COUNTRY") %>'>
Posted 31-May-12 2:52am
manu027928
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You can add

style="overflow:scroll"
or
style="overflow:hidden"
to your label
or add CssClass to your ItemTemplae
and set this style
  Permalink  
Comments
Sandeep Mewara 31-May-12 16:08pm
   
5!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi,
you can set class or style for your label.
Es:
<asp:label text="..." runat="server"
    style="width:200px; height:200px; white-space: nowrap(or normal); 
    overflow: hidden(or scroll)"
</asp:label>

otherwise

you can break you text in rowdatabound event:
<asp:label text='<%# breakMyString(Eval("_COUNTRY"), 60) %>' />
protected string breakMyString(string inString, int len)
{
    string outString = inString;
    string suffix = " more...";
    if (!string.IsNullOrEmpty(inString) && inString.Length > len)
        outString = string.Concat(inString.Substring(0, len - suffix.Length), suffix);
 
    return outString;
}
  Permalink  
v2
Comments
Sandeep Mewara 31-May-12 16:08pm
   
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100