Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 29th, 2008, 06:41 AM
Authorized User
 
Join Date: Jan 2008
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display a string in GridView istead of DB

Hi

I am using a Gridview in my web page. I bind with a sqldatasource and gridview displays all data correctly.
But i want gridview to display an another string instead of the data in database.
For example :
There is a field named "isexists" in my table having 1 or 0 data.
But on the web page , i want to show that column data as "YES" (instead of 1) and "NO" (instead of 0) in gridview.
Could you please help me about this?

Thank you
Jitesh
Programmer



Sharepoint Consulting
__________________
Sharepoint Consulting
  #2 (permalink)  
Old February 29th, 2008, 05:20 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Override the RowDataBound event. This event fires once for every row, and do something like this:

void grid_RowDataBound(..)
{
  if (e.Row.RowType != DataControlRowType.DataRow)
    return;

  e.Row.Cells[index].Text = (e.Row.Cells[index].Text == "1" ? "Yes" : "No");
}

Brian
  #3 (permalink)  
Old March 4th, 2008, 04:57 AM
Authorized User
 
Join Date: Jan 2008
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi there,

           I am Thank full for your response, that's indeed a good solution. i will defiantly try it out.but is there any other way to do so.

Any replies or suggestion is most welcome.

Thanking you
Jitesh
Programmer


Sharepoint Consulting


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to display the GridView. kcsathish ASP.NET 2.0 Basics 1 July 23rd, 2008 04:08 AM
gridview image display Sheraz Khan ASP.NET 2.0 Basics 1 September 2nd, 2007 11:37 PM
Display image in gridview Sheraz Khan ASP.NET 2.0 Professional 0 August 30th, 2007 10:36 PM
Gridview number of records display jodojan ASP.NET 2.0 Basics 3 April 14th, 2007 05:29 AM
GridView doesn't display bnorg ASP.NET 2.0 Professional 1 December 1st, 2006 10:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.