Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 781
  • Last Modified:

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

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
zoobird
Asked:
zoobird
  • 2
  • 2
1 Solution
 
naveenkohliCommented:
Here is a nice little article in MSDN..

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

Naveen
0
 
zoobirdAuthor Commented:
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
 
naveenkohliCommented:
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
 
zoobirdAuthor Commented:
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
 
NetminderCommented:
Question abandoned by Experts; points refunded and question closed.

Netminder
EE Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now