Solved

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

Posted on 2002-04-17
5
742 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now