Solved

display only 50 character....in gridview

Posted on 2006-06-21
6
630 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 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