html - Dynamically change the class of a div nested in a gridview item template from code behind c# -


i need change class of div nested inside gridview item template, have given runat="server" tag , id div. how can change class of particular div upon gridview databind based on each row conditions.

aspx

<asp:gridview id="gv" runat="server" onrowdatabound="gv_onrowdatabound">     <columns>         <asp:templatefield>             <itemtemplate>                 <div id="yourdiv" runat="server"></div>             </itemtemplate>         </asp:templatefield>     </columns> </asp:gridview> 

code-behind

protected void gv_rowdatabound(object sender, gridviewroweventargs e) {     if (e.row.rowtype == datacontrolrowtype.datarow) {         htmlgenericcontrol div = (htmlgenericcontrol)e.row.findcontrol("yourdiv");         div.attributes.add("class", "classyouwanttoadd");     } } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -