|
|
 |
| ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

March 14th, 2007, 09:19 AM
|
|
Wrox Author
Points: 12,827, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
Datagrid Item Template question
Hello everyone,
I am not sure if this is possible, but I am going to ask anyway. I am working with a Databound datagrid and have setup
<columns>
<itemtemplate>
</itemtemplate>
</columns>
for all of the columns in my datagrid. By default I load a CSS Style that is applied to every row and every column in the grid. But now I have the need to change the style of a row if a column holds a certain value. Psuedo code is:
if column value = x
then row style = z
else
row style = default
Does anyone know if this is possible?
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click  on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
|

March 14th, 2007, 09:28 AM
|
|
Wrox Author
Points: 12,827, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
Blah. I hate when the answer to a question is apparent and I over look it. If you need to do conditional formatting to a datagrid, handle the ItemDataBound or ItemCreated event.
Your solution might look something like this:
Code:
private void dg_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView rv = (DataRowView)e.Item.DataItem;
DateTime dt = Convert.ToDateTime(rv.Row.ItemArray[8]);
if (DateTime.Compare(DateTime.Now, dt) > 0)
{
for(int i=0; i < e.Item.Cells.Count; i++)
{
e.Item.Cells[i].CssClass = "lapsedText";
}
}
}
}
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
|

March 14th, 2007, 10:06 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2004
Location: , , India.
Posts: 547
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Yeah
I too was surprised to see this issue raised by you, but it happens, there's a famous saying "Even Einstein asked questions" . ( I am not comparing you with Einstein) :)
Regards
Mike
Fortune favours the brave, so don't regret on missed oppurtunities.
|

March 14th, 2007, 10:08 AM
|
|
Wrox Author
Points: 12,827, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
I, obviously, haven't had enough coffee yet this morning >< Ahh its going to be one of those days.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |