Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. only one line in datagrid cell

only one line in datagrid cell

Scheduled Pinned Locked Moved ASP.NET
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haytham_mohammad
    wrote on last edited by
    #1

    i have a column in datagrid that expose the company name....when the name of the company is long it is divided into multiple lines ...i want to force these lines to be one line and the remaining of the name is hide when the mouse over it, the remaining of the name appear

    haitham

    T 1 Reply Last reply
    0
    • H haytham_mohammad

      i have a column in datagrid that expose the company name....when the name of the company is long it is divided into multiple lines ...i want to force these lines to be one line and the remaining of the name is hide when the mouse over it, the remaining of the name appear

      haitham

      T Offline
      T Offline
      thomasa
      wrote on last edited by
      #2

      Hers a custom control you can use: using System; using System.Web.UI.WebControls; namespace My.Controls{ public class TruncLabel :Label { public TruncLabel() : base (){} protected override void Render(System.Web.UI.HtmlTextWriter writer){ this.CssClass="fxS"; this.ToolTip = this.Text; base.Render(writer); } } } Your stylesheet should then contain the following: .fxS { overflow:hidden; white-space:nowrap; overflow-clip:rect(auto, auto, auto, auto); } The page containing the datagrid <%@ Register TagPrefix="mi" Namespace="My.Controls" Assembly="MyProjectOrSomething" %> . . asp:datagrid id="myDataGrid" runat="server" CssClass="grid" GridLines="None" AutoGenerateColumns="False"> Columns> asp:TemplateColumn HeaderText="Name" ItemStyle-VerticalAlign="Top"> ItemTemplate> mi:TruncLabel id="tlblName" Font-Bold="True" runat="server"> <%#DataBinder.Eval(Container.DataItem, "strCompanyName").ToString()%> mi:TruncLabel> ItemTemplate> asp:TemplateColumn> Columns>

      H 1 Reply Last reply
      0
      • T thomasa

        Hers a custom control you can use: using System; using System.Web.UI.WebControls; namespace My.Controls{ public class TruncLabel :Label { public TruncLabel() : base (){} protected override void Render(System.Web.UI.HtmlTextWriter writer){ this.CssClass="fxS"; this.ToolTip = this.Text; base.Render(writer); } } } Your stylesheet should then contain the following: .fxS { overflow:hidden; white-space:nowrap; overflow-clip:rect(auto, auto, auto, auto); } The page containing the datagrid <%@ Register TagPrefix="mi" Namespace="My.Controls" Assembly="MyProjectOrSomething" %> . . asp:datagrid id="myDataGrid" runat="server" CssClass="grid" GridLines="None" AutoGenerateColumns="False"> Columns> asp:TemplateColumn HeaderText="Name" ItemStyle-VerticalAlign="Top"> ItemTemplate> mi:TruncLabel id="tlblName" Font-Bold="True" runat="server"> <%#DataBinder.Eval(Container.DataItem, "strCompanyName").ToString()%> mi:TruncLabel> ItemTemplate> asp:TemplateColumn> Columns>

        H Offline
        H Offline
        haytham_mohammad
        wrote on last edited by
        #3

        thanks for your reply but can`t we use the ordinary label and change cssclass and tooltip properties of this label?.. i will try it and tell u thanks again for your help....

        haitham

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups