2014年7月13日 星期日

[RESOLVED] Change Backcolor on Template Field


I would like to change the Backcolor of this Template field based on the output of this function.




<%# OTDClass(Eval("OTDClass").ToString(), Eval("Hide").ToString())%>


I have tried to do this at the RowDataBound event as well as the RowCreated events.


        If e.Row.Cells(4).Text = "Shipped" Then
e.Row.Cells(4).BackColor = System.Drawing.Color.Gold
End If

Neither seem to have any effect on the backcolor.


Is there anthor method IO can use here?



Hi,


Create a style like :



then in code behind,


write code


If e.Row.Cells(4).Text = "Shipped" Then
e.Row.Cells[0].CssClass ="bb"
End If


Hope it helps.


related topic link:




Unfortunately no.  


I belive that's because the Function inside the template is being evaluated after the RowDataBound and RowCreated events are fired.


I can only guess I need to move the " IF " statement to a different event.




Try If e. Row. Cells ( 4 ). Text.ToLower() = "shipped" Then... Try also using label and FindControl.

Hi,


Try wrapping up the template field inside a div and apply styles to div


Ex:





<%# OTDClass(Eval("OTDClass").ToString(), Eval("Hide").ToString())%>








沒有留言:

張貼留言