Hi slm3003 I have tested your code and Its working fine. CSS is making row both underline and bold. You can check wether is any other class is not over riding your css styles.
If use a css class and e.row.cssClass="style"; Then no change to that row at all. It become neither bold nor underlined. How can I make the same row both bold and underline?
Below are 3 possible solutions, you are free to choose one ...
FYI -- following did worked in my OnRowDataBound event handler, you may want to make sure that this formatting is not being overridden in your css / html attributes that you're using in the mark-up,
slm3003
Member
133 Points
166 Posts
Making a row of gridview both bold and underline
Dec 10, 2012 02:34 AM|LINK
I have a gridview and on rowdatabound i want to make one particular row both bold and underline. I have the code like this
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int rowIndex = e.Row.RowIndex;
if (rowIndex == 9)
{
e.Row.Font.Bold = true;
e.Row.Font.Underline = true;
}
}
}
The row becomes only bold but not underlined. If use a css class like
.style {
font-weight:bold;
text-decoration:underline;
}
and e.row.cssClass="style";
Then no change to that row at all. It become neither bold nor underlined. How can I make the same row both bold and underline?
2pac
Participant
1586 Points
269 Posts
Re: Making a row of gridview both bold and underline
Dec 10, 2012 02:55 AM|LINK
Hi,
I just tested the above code, it works fine from my end.
regards,
Jayesh
Regards,
Jayesh
2pac
Participant
1586 Points
269 Posts
Re: Making a row of gridview both bold and underline
Dec 10, 2012 02:56 AM|LINK
can you please post a screen shot.
Thank you
Regards,
Jayesh
hafizzeeshan
Participant
834 Points
253 Posts
Re: Making a row of gridview both bold and underline
Dec 10, 2012 03:04 AM|LINK
HI
Please Check the following
protected void YouGrid_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer'; this.style.textDecoration='underline';"; e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';"; } } catch { } }Zeeshan Rauf
# 92-3216698206
Email : zeeshan_rouf@hotmail.com
Please mark the replies as answers if they help or unmark if not.
oned_gk
All-Star
31798 Points
6499 Posts
Re: Making a row of gridview both bold and underline
Dec 10, 2012 03:17 AM|LINK
try clear all style related to the GV first and test the code again.
anuj_koundal
Contributor
2088 Points
496 Posts
Re: Making a row of gridview both bold and underline
Dec 10, 2012 03:20 AM|LINK
Hi slm3003 I have tested your code and Its working fine. CSS is making row both underline and bold. You can check wether is any other class is not over riding your css styles.
Regards
Anuj Koundal
aarsh
Participant
1543 Points
428 Posts
Re: Making a row of gridview both bold and underline
Dec 10, 2012 03:57 AM|LINK
Below are 3 possible solutions, you are free to choose one ...
protected void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';"; e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';"; e.Row.ToolTip = "Click to select row"; e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex); } }Alernatively ...
protected void GridView_RowDatabound(object sender, GridViewRowEventArgs e) { foreach (TableCell c in e.Row.Cells) { c.Style.Clear(); c.Style.Add("font-weight", "bold"); c.Style.Add("border-bottom", " #800080 3px double"); } }Also, I can recommand you to read this article : http://msdn.microsoft.com/en-us/library/1yef90x0%28VS.80%29.aspx
FYI -- following did worked in my OnRowDataBound event handler, you may want to make sure that this formatting is not being overridden in your css / html attributes that you're using in the mark-up,
protected void GridView_RowDatabound(object sender, GridViewRowEventArgs e) { e.Row.Font.Bold = true; e.Row.Font.Underline = true; ...slm3003
Member
133 Points
166 Posts
Re: Making a row of gridview both bold and underline
Dec 10, 2012 01:44 PM|LINK
Thnx aarsh, it worked. When I put e.row.font.bold=true and e.row.font.underline=ture inside the foreach loop then it is working fine.