Solved

Setting a DataGrid row/column format programmatically in ASP.NET

Posted on 2002-04-17
5
752 Views
Last Modified: 2008-03-17
I am new to the .NET platform. I have created a DataGrid whose DataSource is a table I create programatically. I want to be able to programatically manipulate the style of the column and rows of the datagrid, such as be able to create a hyperlink column, or make an entire row's font color Red. I am using C#. How do I do this? Please provide a code sample.
0
Comment
Question by:zoobird
  • 2
  • 2
5 Comments
 
LVL 23

Expert Comment

by:naveenkohli
ID: 6949259
Here is a nice little article in MSDN..

http://msdn.microsoft.com/msdnmag/issues/01/12/asp/asp0112.asp

Naveen
0
 

Author Comment

by:zoobird
ID: 6950551
It's a good article, but it doesn't answer my problem. I need specifics on how to change the properties of certain columns and rows.
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 6956779
There are couple of things that you can do..

.. Following code will set each line's backgrund color to red. But you can manipulate other propeties too.
private void SetEachRowRed()
{
 myGrid.ItemStyle.BackColor = Color.Red;
}

If you want to manipulate different columns. Then what you can do is, set AutoGenaretColumns attribute of grid to false and then add BoundColumn or other columns explicitly. This way you will be able to control each column's controls. And this will also fill the Columns collection of grid for manipulating later on.

Take a look at the following link.

http://www.pardesiservices.com/Softomatix/DGAutoGen.asp

Naveen
0
 

Author Comment

by:zoobird
ID: 6963299
Naveen,

The thing is, I want to change a random row's background color, not all of the rows, nor alternating rows. I want to highlight certain rows if they meet a set of criteria.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7616185
Question abandoned by Experts; points refunded and question closed.

Netminder
EE Admin
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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