Solved

display only 50 character....in gridview

Posted on 2006-06-21
6
638 Views
Last Modified: 2012-05-05
I have a filed calll "description" in gridview.

I would like to display only 50 character of "description" and replace the rest of characters with ' .....'.

How can I do this in ASP.net 2.0 C#?
0
Comment
Question by:jung1975
  • 2
  • 2
  • 2
6 Comments
 
LVL 7

Expert Comment

by:kGenius
ID: 16954941
  foreach (GridViewRow r in this.GridView1.Rows)
        {
            r.Cells[3].Text = r.Cells[3].Text.Substring(0, 50) + " ...";
        }

//where Cells[3] is your description field
//replace 3 by the column number (zero-based)
0
 
LVL 7

Accepted Solution

by:
kGenius earned 250 total points
ID: 16954946
place it  in GridView_DataBound

kGenius
0
 
LVL 3

Expert Comment

by:brianpsmith81
ID: 16954954
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:jung1975
ID: 16955042
but if I put a mouse over to the column , it should show the whole text? how can I do that? DO I have to use some kind of java script?
0
 
LVL 3

Expert Comment

by:brianpsmith81
ID: 16955192
word of advice...don't award someone points and then ask another question under the same question...especially one that's arguably harder than the original.  There's no point in us answering with the motivation of points gone, especially for those that didn't receive any.  If you really need an answer, you should start a new question.  (Not trying to be a jerk, just giving a tip).
0
 

Author Comment

by:jung1975
ID: 16955477
got your point.. forgot to split the point..
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question