Solved

display only 50 character....in gridview

Posted on 2006-06-21
6
643 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: 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.

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…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 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