changing the css dynamically in asp.net
I have a gridview inside an update panel.In that gridview, I have a linkbutton in which i need to show the status.If the linkbutton text is success then it should be in same color. and if the linkbutton text is fail,it shou开发者_运维知识库ld be in red color.I have written the css for red color.
Here the default is blue.How to change it red when the linkbutton returns false??
Thanks
You could use GridView's RowDataBound event to change the CSS accordingly.
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Select Case e.Row.RowType
Case DataControlRowType.DataRow
Dim data = DirectCast(e.Row.DataItem, DataRowView)
Dim LnkStatus = DirectCast(e.Row.FindControl("LnkStatus "), LinkButton)
If data("Status").ToString.ToLower = "fail" Then
LnkStatus.CssClass = "FailedStatus"
End If
End Select
End Sub
精彩评论