Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 25, 2010 03:19 AM by Pikesville Paesano
Member
25 Points
37 Posts
Aug 25, 2010 02:19 AM|LINK
I was highlighting certain rows in my gridview using code like this in the DataBound event:
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (something)
e.Row.BackColor = System.Drawing.Color.Gray;
e.Row.ForeColor = System.Drawing.Color.White;
}
This doesn't work anymore with the CSSFriendly adapter for Gridview. I tried changing the style of the row, but nothing shows up in the source for the page.
Any thoughts?
CSS Friendly Control Adapters GridView
Participant
1036 Points
197 Posts
Aug 25, 2010 03:19 AM|LINK
I don't think the Databound event is where I'd be doing formatting. I don't recommend logic in the aspx page, either for thaat matter.
a few articles http://softwarekeith.com/
ttp://www.15seconds.com/Issue/020102.htm
my advice would be to use JQuery to manage the CSS via class injection
jcorey
Member
25 Points
37 Posts
Can't change Gridview row colors or styles in the DataBound event
Aug 25, 2010 02:19 AM|LINK
I was highlighting certain rows in my gridview using code like this in the DataBound event:
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> if (e.Row.RowType == DataControlRowType.DataRow)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> {</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> int vendorCheck = 0;</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> //TODO make this shorter</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> if (DataBinder.Eval(e.Row.DataItem, "vendorId") != System.DBNull.Value)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> {</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> vendorCheck = System.Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "vendorId"));</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> }</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> if (vendorCheck == WebUtils.GetClientId())</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> {</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> e.Row.CssClass = "vendorBackColor";</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> e.Row.BackColor = System.Drawing.Color.Gray;</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> e.Row.ForeColor = System.Drawing.Color.White;</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> }</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> }</div> <div></div>if (e.Row.RowType == DataControlRowType.DataRow)
{
if (something)
{
e.Row.BackColor = System.Drawing.Color.Gray;
e.Row.ForeColor = System.Drawing.Color.White;
}
}
This doesn't work anymore with the CSSFriendly adapter for Gridview. I tried changing the style of the row, but nothing shows up in the source for the page.
Any thoughts?
<div></div>
CSS Friendly Control Adapters GridView
Pikesville P...
Participant
1036 Points
197 Posts
Re: Can't change Gridview row colors or styles in the DataBound event
Aug 25, 2010 03:19 AM|LINK
I don't think the Databound event is where I'd be doing formatting. I don't recommend logic in the aspx page, either for thaat matter.
a few articles http://softwarekeith.com/
ttp://www.15seconds.com/Issue/020102.htm
my advice would be to use JQuery to manage the CSS via class injection
You haven't had a beer until you've learned how to make your own...