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. Help need in gridview

Help need in gridview

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestion
5 Posts 5 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.
  • S Offline
    S Offline
    Senthil S
    wrote on last edited by
    #1

    Hai All, I need little help in asp.net gridview, i want to create a gridview in which the column width is fixed and the data in the column should have dot line(somthing data....) if it the length of the data is more than the width? Can an give me an idea? or suggestions. That will great for me.. Can any one??? Thanks in Advance.... with regards,

    Senthil.S A Software Engineer

    P R T 3 Replies Last reply
    0
    • S Senthil S

      Hai All, I need little help in asp.net gridview, i want to create a gridview in which the column width is fixed and the data in the column should have dot line(somthing data....) if it the length of the data is more than the width? Can an give me an idea? or suggestions. That will great for me.. Can any one??? Thanks in Advance.... with regards,

      Senthil.S A Software Engineer

      P Offline
      P Offline
      Padmanabh Ganorkar
      wrote on last edited by
      #2

      Hi Senthil, You can use GridView's RowDataBound Event for your task. The RowDataBound Event is raised while binding each and every row from DataSource. Here you can check the string length and do the stuff you want to do on it. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { // Suppose 4th Cell has your huge Text if (e.Row.Cells[3].Text.Length > 150) { // Write Truncating Logic Here } } }I Hope This Helps. :) Thanks, Padmanabh

      1 Reply Last reply
      0
      • S Senthil S

        Hai All, I need little help in asp.net gridview, i want to create a gridview in which the column width is fixed and the data in the column should have dot line(somthing data....) if it the length of the data is more than the width? Can an give me an idea? or suggestions. That will great for me.. Can any one??? Thanks in Advance.... with regards,

        Senthil.S A Software Engineer

        R Offline
        R Offline
        Ravi_21
        wrote on last edited by
        #3

        Just do one thing take that column as tamplate column and wite a protacted function from code behind in that protacted function u just take the data from the database column which u have to dispaly and count the lenght of the String and take one for loop from 0 to say 50 words and take one string builder and create one table from code behind when the looop reaches the maximum character u have provide then take one ancor tag dispaly.... and u can navigate to next page for whole description of that column

        1 Reply Last reply
        0
        • S Senthil S

          Hai All, I need little help in asp.net gridview, i want to create a gridview in which the column width is fixed and the data in the column should have dot line(somthing data....) if it the length of the data is more than the width? Can an give me an idea? or suggestions. That will great for me.. Can any one??? Thanks in Advance.... with regards,

          Senthil.S A Software Engineer

          T Offline
          T Offline
          Tarun Dudhatra
          wrote on last edited by
          #4

          HI Senthil Use this code in Aspx page inside gridview Column Heading <%#FormatString(Eval("ColumnName").ToString(),20)%> in .cs file just write down this function public string FormatString(string strval, int length) { string temp = strval; if (temp.Length > length) temp = temp.Substring(0, length - 3) + "..."; return temp; } Just guese here I am passing 20 as a lenth variable so it will add ... if string is more than 20 characters http://techiefromsurat.blogspot.com/

          E 1 Reply Last reply
          0
          • T Tarun Dudhatra

            HI Senthil Use this code in Aspx page inside gridview Column Heading <%#FormatString(Eval("ColumnName").ToString(),20)%> in .cs file just write down this function public string FormatString(string strval, int length) { string temp = strval; if (temp.Length > length) temp = temp.Substring(0, length - 3) + "..."; return temp; } Just guese here I am passing 20 as a lenth variable so it will add ... if string is more than 20 characters http://techiefromsurat.blogspot.com/

            E Offline
            E Offline
            Elayaraja Sambasivam
            wrote on last edited by
            #5

            use css style for table Cell. this can be added from server side while rendering the grid cell. style.textOverflow = 'ellipsis' Or you can iterate the grid cells as TD , set the below attribute to the TD. TDCell.style.textOverflow = 'ellipsis'

            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