Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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
 
Old May 19th, 2006, 05:07 AM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with the DataGrid

Hi i'm new to ASP.NET

Please help me with the following problem.

I have the column by name 'Role' in my Datagrid. This column should display the role of employees either as 'Leader' or 'Member' based on the value retrieved from the database. The value i retrieve is 'Y' or 'N'. So if the value is 'Y', then the column should display as 'Leader' otherwise as 'Member'.

How can i make it up!!

Kindly Suggest!!

Thanks in advance!!:)
 
Old May 19th, 2006, 08:35 AM
Registered User
 
Join Date: May 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i think u r using dataset to bind the datagrid..

before assigning datasource to the dataset [ 'DataGrid1.DataSource = ds']
u have to check the value y or N.

just add this line before setting datasource to dataset

just spcify the column index as item.. if 'Y' returned as column 3 means u can specify item(3)

if(ds.tables(0).rows(0),items(0)='Y')
     ds.tables(0).rows(0),items(0)='Leader'
else
     ds.tables(0).rows(0),items(0)='Member'
endif

DataGrid1.DataSource = ds
ds.databind



if u have returned more than one row from DB, u can make a loop and do it..

===========
Ram
 
Old May 19th, 2006, 10:00 AM
Authorized User
 
Join Date: May 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ram has told the correct way and I will too suggest the same way for
doing this stuff

rajkumar sharma
 
Old May 22nd, 2006, 05:59 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

Hi all,

if you are using sql server then just put case statement in your select query to create a derived column and give an alias to your derived column. Inthis way you will save extra time to parse the data and change the column values. For details , consult Sql server help for use of case statement in select queries.
I hope it will help you

Anubhav Kumar
 
Old May 25th, 2006, 09:04 AM
Registered User
 
Join Date: May 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thats better time.. it reduces lots of time in fron end

====
Ram





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with datagrid Shishir ASP.NET 1.0 and 1.1 Professional 1 January 6th, 2007 09:01 AM
Datagrid Problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 December 5th, 2006 03:09 AM
DataGrid Problem anujrathi VB.NET 2002/2003 Basics 2 June 15th, 2006 02:18 AM
DataGrid Problem anujrathi ASP.NET 2.0 Basics 1 June 12th, 2006 03:52 PM
Datagrid problem dotnetprogrammer VS.NET 2002/2003 1 February 17th, 2005 05:11 AM





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