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