简体   繁体   English

CSS类没有在后面的代码中删除

[英]Css class not getting removed in code behind

I have the following code for Gridview: 我有以下用于Gridview的代码:

<SelectedRowStyle CssClass="SelectedRowStyle" />

where I change the selected row to yellow color. 我将所选行更改为黄色。

And then on a button click I want to remove the css class. 然后在按钮上单击“我要删除css类”。 I tried to handle that in code by following: 我尝试通过以下方式在代码中进行处理:

Gridview1.SelectedRow.CssClass=
Gridview1.SelectedRow.CssClass.Replace("SelectedRowStyle","")

Gridview1.SelectedRowStyle.CssClass=
Gridview1.SelectedRowStyle.CssClass.Replace("SelectedRowStyle","");

Gridview1.SelectedRow.Attributes.Remove("SelectedRowStyle");

But nothing works. 但是什么都行不通。 Where am I going wrong ? 我要去哪里错了?

只需将空字符串分配给CssClass属性,并记住您将需要重新绑定网格视图以获取更改

Gridview1.SelectedRow.CssClass = "";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM