javascript - 如何根据它的字段值设置行颜色。来自asp.net中的客户端
问题描述
我正在使用网格视图来显示一个表格,并使用 onRowDataBound 来执行一个根据字段值设置颜色的函数
函数定义是这样的
{
e.Row.Cells[3].Visible = false;
if (e.Row.Cells[3].Text == "0")
{
e.Row.ForeColor = System.Drawing.Color.Red;
}
}
我想知道如何从客户端而不是服务器端完成此操作。
解决方案
为客户端找到了这个基本示例
尝试调整它以使用视图中的数据并添加我猜你可以通过 css 放置颜色。
<div>
<table>
<tr>
<td style="width: 100px">StuId
</td>
<td style="width: 150px">StuName
</td>
<td style="width: 100px">Course
</td>
</tr>
</table>
<asp:GridView AutoGenerateColumns="false" OnDataBound="GridView1_DataBound" OnRowDataBound="GridView1_RowDataBound" ID="GridView1" runat="server">
<Columns>
<asp:BoundField DataField="StuId" HeaderText="StuId" ItemStyle-Width="100px" />
<asp:BoundField DataField="StuName" HeaderText="StuName" ItemStyle-Width="150px" />
<asp:BoundField DataField="Course" HeaderText="Course" ItemStyle-Width="100px" />
</Columns>
</asp:GridView>
</div>
文章:https ://www.codeproject.com/Articles/249155/Rows-and-Columns-Merging-in-ASP-NET-GridView-Contr
推荐阅读
- php - SimpleSAMLphp 的 SessionHook?
- javascript - react-custom-scrollbars - 如何更改水平滚动轨道颜色?
- google-apps-script - “缺少;”的错误 我无法解决
- amazon-s3 - 将文件上传到 S3 时的 OptionsRequestDenied
- android - 如何从 Android Youtube API 获得视频质量?
- java - 为什么我的 Android 应用程序不适用于某些 Android 版本?
- vba - 我的循环是使用 Next 跳转一行
- ios - iOS:通过 CATransform3DRotate 旋转时跳转 uiview
- corda - Cordapp 中的多个版本的流程
- javascript - 在 Firestore 中获取嵌套文档