如何将CSS类添加到BoundField,以便可以使用jQuery找到它? [英] How do I add a CSS class to a BoundField, so I can find it with jQuery?

查看:140
本文介绍了如何将CSS类添加到BoundField,以便可以使用jQuery找到它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在GridView控件的某些BoundField中添加一个类名;这样,一旦GridView进行了数据绑定和渲染,我就可以获得类似的东西:

I want to add a class name to some of my BoundFields in the GridView control; so that once the GridView is data-bound and rendered I can obtain something like:

<td class="Tag1">Some data came from data source</td>

执行此操作的目的是能够以这种方式找到所有"Tag1"元素:

The purpose of doing such a thing is to be able to find all the elements that are "Tag1" in this way:

var allTag1td = $('td.Tag1');

那么,如何将此类添加到BoundField中,以使其以这种方式呈现?

So, how can I add this class to the BoundField so that it is rendered in this way?

推荐答案

您不能直接在aspx中设置绑定域的itemstyle属性吗?

Can you not directly set the itemstyle property of your boundfield in the aspx?

(TableItemstyle具有CssClass属性)

(TableItemstyle has a CssClass property)

<asp:BoundField ItemStyle-CssClass="Tag1"/>

请参阅:

  • http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datacontrolfield.itemstyle.aspx
  • http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.tableitemstyle_properties.aspx

这篇关于如何将CSS类添加到BoundField,以便可以使用jQuery找到它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆