Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET如何更改按钮单击时表格行的背景色+;行条目?_C#_Javascript_Jquery_Html_Asp.net - Fatal编程技术网

C# ASP.NET如何更改按钮单击时表格行的背景色+;行条目?

C# ASP.NET如何更改按钮单击时表格行的背景色+;行条目?,c#,javascript,jquery,html,asp.net,C#,Javascript,Jquery,Html,Asp.net,我有一个表,其中有一行在用户单击按钮后填充了值。我想根据填充到行中的值将行的背景色更改为不同的颜色 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Search" /> <tr> <td runat="server" id ="td1" class="auto-style1"></td> <td runat="server" id ="

我有一个表,其中有一行在用户单击按钮后填充了值。我想根据填充到行中的值将行的背景色更改为不同的颜色

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Search" />
<tr>
    <td runat="server" id ="td1" class="auto-style1"></td>
    <td runat="server" id ="td2" class="auto-style1"></td>
    <td runat="server" id ="td3" class="auto-style1"></td>
    <td runat="server" id ="td4" class="auto-style1"></td>
</tr>

基本上,我想根据toDisp[1]的值设置表行的背景色。我该怎么做呢?谢谢。

如果只有一排的话

只需使用runat属性为其设置一个ID

<tr id="test" runat="server">
    <td runat="server" id ="td1" class="auto-style1"></td>
    <td runat="server" id ="td2" class="auto-style1"></td>
    <td runat="server" id ="td3" class="auto-style1"></td>
    <td runat="server" id ="td4" class="auto-style1"></td>
</tr>

是否存在表示颜色的常量?
<tr id="test" runat="server">
    <td runat="server" id ="td1" class="auto-style1"></td>
    <td runat="server" id ="td2" class="auto-style1"></td>
    <td runat="server" id ="td3" class="auto-style1"></td>
    <td runat="server" id ="td4" class="auto-style1"></td>
</tr>
test.BgColor = "SomeColor";