Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

How can i change span's class in C# ?

$
0
0

the following code is under gridview1, can't get the span's ID directly so i use findcontrol instead

<asp:TemplateField HeaderText="Reply">
<ItemTemplate>
<span id="convertsantionCount" class="label label-success"><%# Portal.Message.getConversationCount(Eval("ID").ToString())%></span>
</ItemTemplate>
</asp:TemplateField>

System.Web.UI.HtmlControls.HtmlGenericControl control = (System.Web.UI.HtmlControls.HtmlGenericControl) GridView1.FindControl("convertsantionCount");
control.Attributes["class"] = "badge badge-warning";

it says the control.Attributes["class"] Object reference not set to an instance of an object.

anyone would tell me how can i mannually change the class of the span. any way would do much thanks.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>