Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Import csv files to MS SQL 5 85
Questions about INCLUDE FILES 2 37
Connecting to multiple databases to create a Dashboard 5 48
Writing comments on <p></P> or paragraph 2 19
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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