473,379 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Dataset Row Formatting/Style in DataGris

I have a Dataset (ds) binded to a Datagrid (dg).

Based on a value in a Datacolumn (dc) within the Datarow (dr) of the ds, I
want the dr to be displayed in either black or red text. If the dc column is
1, then display the row in black, if the value is 0 then display in red.

What is the easiest way to achieve this?

I could just hack my way by appending HTML text so some Label string.

But I was wondering if there was a more elegant way of doing this? Perhaps
through an ItemTemplate of the dg?

Does anyone know of any examples of doing something like this?


Aug 15 '06 #1
2 860
Check out this code sample from http://aspnet101.com:
http://aspnet101.com/aspnet101/aspne...itionalcolordg
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"Paul" <Pa**@discussions.microsoft.comwrote in message
news:A8**********************************@microsof t.com...
I have a Dataset (ds) binded to a Datagrid (dg).

Based on a value in a Datacolumn (dc) within the Datarow (dr) of the ds, I
want the dr to be displayed in either black or red text. If the dc column
is
1, then display the row in black, if the value is 0 then display in red.

What is the easiest way to achieve this?

I could just hack my way by appending HTML text so some Label string.

But I was wondering if there was a more elegant way of doing this? Perhaps
through an ItemTemplate of the dg?

Does anyone know of any examples of doing something like this?


Aug 15 '06 #2
Thank you very much. This is exactly what I was looking for.

"David Wier" wrote:
Check out this code sample from http://aspnet101.com:
http://aspnet101.com/aspnet101/aspne...itionalcolordg
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com

"Paul" <Pa**@discussions.microsoft.comwrote in message
news:A8**********************************@microsof t.com...
I have a Dataset (ds) binded to a Datagrid (dg).

Based on a value in a Datacolumn (dc) within the Datarow (dr) of the ds, I
want the dr to be displayed in either black or red text. If the dc column
is
1, then display the row in black, if the value is 0 then display in red.

What is the easiest way to achieve this?

I could just hack my way by appending HTML text so some Label string.

But I was wondering if there was a more elegant way of doing this? Perhaps
through an ItemTemplate of the dg?

Does anyone know of any examples of doing something like this?




Aug 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tom Vukovich | last post by:
and returning the xml to the requesting web page, how do you insert the XML declaration? ds.EnforceConstraints = False Response.ContentType = "text/xml" ds.WriteXml(Response.OutputStream,...
1
by: glenn | last post by:
I have written as a test a customer class that has all the necessary field handling and formatting routines in it that I need. I have dataaccess class that controls reading and writing the class...
12
by: Bishoy George | last post by:
I have a dataset called ds1 filled with 2 tables Employees and Customers from Northwind database. I have dropdownList called ddLastName with the following properties: ddLastName.DataSource =...
10
by: Coleen | last post by:
Hi all :-) I have a weird formatting problem with an HTML table that I am populating using VB.Net and HTML. Here is the snippet of code for the cell I'm trying to format: Dim...
4
by: Arthur Dent | last post by:
Hello all, ive been programming with ASP.NET since it came out, but am just getting my feet with now with v.2. Ive noticed something strange in the way my HTML tables get rendered with 2. I use...
0
by: Randall Arnold | last post by:
I have a Microsoft Access report (built on a SQL Server 2000 query) I have exported as xml/html. I include a stylesheet in the original export for formatting of the report. The schema is...
1
by: Mike | last post by:
Hello all, Is there a way to change the ItemTemplate based on the data that is being shown? For instance, I have a dataset, contains two fields (NAME, STATE). I want to show all the records...
5
by: mrid via DotNetMonster.com | last post by:
hi. im exporting data from a vb form to excel. i am able to create a new excel file, save and edit it without any trouble, but the formatting is giving me hell! i need to be able to show certain...
1
by: Josiwe | last post by:
I have a search program that returns an HTML string which I display to the user. I want to highlight the search terms. However a simple search and replace on the HTML causes problems. If the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.