Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 03, 2012 11:02 AM by oned_gk
Member
13 Points
34 Posts
Dec 03, 2012 09:50 AM|LINK
I have a sharepoint 2010 SPGridview and i want to change its cell color on one condition.My condition is
string strRemoveDollar = e.Row.Cells[12].Text.ToString();
decimal theValue = Convert.ToDecimal(strRemoveDollar);
if (theValue < 17) {
e.Row.Cells[12].BackColor = Color.Red; }
else if (theValue < 10) {
e.Row.Cells[12].BackColor = Color.Green; }
How i accomplish this, where to put code so my cell color gets change on condition provided.
SPGridView storeSPGrid = new SPGridView();
Participant
834 Points
253 Posts
Dec 03, 2012 10:38 AM|LINK
hi
Please Follow the following Steps
1 ) make javascript function according to your requirement
function rowClick(val) { document.getElementById('<%= hfSelectedRow.ClientID %>').value = val; document.getElementById('<%= hfDetailsClicked.ClientID %>').value = "1"; }
2 ) Working o nRowDataBound
protected void MyGrid_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';"; e.Row.Attributes.Add("onclick", "javascript:rowClickOutw('" + e.Row.RowIndex + "'); return false;"); } } catch { } }
Regards
Zeeshan Rouf
Dec 03, 2012 10:59 AM|LINK
Hi Hafizz,
I have to bind it from code behind not from click event.
It check condition for all row and set red and green on the base of it.and it will fix till user close the link.
Please suggest some code behind approached for the same.
All-Star
31237 Points
6384 Posts
Dec 03, 2012 11:02 AM|LINK
mangesh.barm...
Member
13 Points
34 Posts
Change sharepoint 2010 SPGridview cell color on condition?
Dec 03, 2012 09:50 AM|LINK
I have a sharepoint 2010 SPGridview and i want to change its cell color on one condition.My condition is
string strRemoveDollar = e.Row.Cells[12].Text.ToString();
decimal theValue = Convert.ToDecimal(strRemoveDollar);
if (theValue < 17) {
e.Row.Cells[12].BackColor = Color.Red; }
else if (theValue < 10) {
e.Row.Cells[12].BackColor = Color.Green; }
How i accomplish this, where to put code so my cell color gets change on condition provided.
SPGridView storeSPGrid = new SPGridView();
hafizzeeshan
Participant
834 Points
253 Posts
Re: Change sharepoint 2010 SPGridview cell color on condition?
Dec 03, 2012 10:38 AM|LINK
hi
Please Follow the following Steps
1 ) make javascript function according to your requirement
function rowClick(val) { document.getElementById('<%= hfSelectedRow.ClientID %>').value = val; document.getElementById('<%= hfDetailsClicked.ClientID %>').value = "1"; }2 ) Working o nRowDataBound
protected void MyGrid_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';"; e.Row.Attributes.Add("onclick", "javascript:rowClickOutw('" + e.Row.RowIndex + "'); return false;"); } } catch { } }Regards
Zeeshan Rouf
Zeeshan Rauf
# 92-3216698206
Email : zeeshan_rouf@hotmail.com
Please mark the replies as answers if they help or unmark if not.
mangesh.barm...
Member
13 Points
34 Posts
Re: Change sharepoint 2010 SPGridview cell color on condition?
Dec 03, 2012 10:59 AM|LINK
Hi Hafizz,
I have to bind it from code behind not from click event.
It check condition for all row and set red and green on the base of it.and it will fix till user close the link.
Please suggest some code behind approached for the same.
oned_gk
All-Star
31237 Points
6384 Posts
Re: Change sharepoint 2010 SPGridview cell color on condition?
Dec 03, 2012 11:02 AM|LINK