如何动态添加CSS类到GridEditCommandColumn中 [英] how to add css class into GridEditCommandColumn in dynamically

查看:93
本文介绍了如何动态添加CSS类到GridEditCommandColumn中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我在这里写了这样的代码

hi
Here i wrote the code like this

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
       GoalGrid()
       ParticipantGrid()
   End Sub





Public Sub GoalGrid()
        AddHandler grdGoalLevel.NeedDataSource, AddressOf grdGoalLevel_NeedDataSource
        AddHandler grdGoalLevel.ItemCreated, AddressOf grdParticipants_ItemCreated
        AddHandler grdGoalLevel.ItemCommand, AddressOf grdParticipants_ItemCommand
        AddHandler grdGoalLevel.UpdateCommand, AddressOf grdParcipants_UpdateCommand
        Dim index As Integer = 0
        grdGoalLevel.MasterTableView.EditMode = GridEditMode.InPlace

        Dim editColumn As New GridEditCommandColumn
        editColumn.ButtonType = GridButtonColumnType.ImageButton
        editColumn.EditImageUrl = "~/Assets/image/core/note_btn.png"
        editColumn.UpdateImageUrl = "~/Assets/image/core/tick_ic.png"
        editColumn.CancelImageUrl = "~/Assets/image/core/cancel_btn.png"



grdGoalLevel.MasterTableView.Columns.AddAt(index,editColumn)

我的问题是在这里EditImageUrl,UpdateEmageUrl,CancelImageUrl被直接赋予图像引用,但是在这里我想通过调用cssClasses添加spriteImages.
我不想



grdGoalLevel.MasterTableView.Columns.AddAt(index, editColumn)

my problum is here EditImageUrl,UpdateEmageUrl, CancelImageUrl are directly given the image references, but here i want to add spriteImages by calling the cssClasses.
i dont want to

editColumn.EditImageUrl = "~/Assets/image/core/note_btn.png"

像这样
我想调用插入〜/Assets/image/core/note_btn.png"的CSS类

所以,请帮助我.

在这里,我尝试过这样的编辑按钮


like this
i want to call css class insted of "~/Assets/image/core/note_btn.png"

so ,please help me anyone.

here i had tried for edit button like this


Dim editColumn As New GridEditCommandColumn
editColumn.ButtonType = GridButtonColumnType.LinkButton
editColumn.ItemStyle.CssClass = "buttonEdit1"



我必须以相同的方式为updateImageurl和cancelImageUrl添加.



in the same way i have to add for updateImageurl and cancelImageUrl.

推荐答案

嗨 您可以使用以下方法添加CommandField的CSS类

静态

Hi You can add CSS Class of CommandField using following method

Static

<asp:commandfield showselectbutton="True" itemstyle-cssclass="cssSelect">
</asp:commandfield>




OR

<asp:commandfield showselectbutton="True" >
<controlstyle cssclass="cssSelect" />
</asp:commandfield>



动态



Dynamic

CommandField cf = new CommandField();
cf.ItemStyle.CssClass = "cssSelect";




OR

cf.ControlStyle.CssClass = "cssSelect";



StyleSheet

如果设置 ItemStyle-CssClass
,则可以设置以下样式



StyleSheet

You can set following style if you set ItemStyle-CssClass

td.cssSelect a
{
    color:Red;
}



如果设置 ControlStyle CssClass
,则可以设置以下样式



You can set following style if you set ControlStyle CssClass

a.cssSelect
{
    color:Red;
}


如果您仍有问题,请告诉我.


Please do let me know, if you have still problem.


这篇关于如何动态添加CSS类到GridEditCommandColumn中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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