如何在“删除链接"按钮上更改Datagrid行的颜色在Datagrid中单击 [英] How to change color of Datagrid row on Delete Link Button Click in Datagrid
本文介绍了如何在“删除链接"按钮上更改Datagrid行的颜色在Datagrid中单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有一个DataGrid,需要在单击Datagrid中的Delete LinkButton时更改datagrid中行的颜色.
请帮忙.
谢谢.
Hi
I am having a DataGrid and need to change the color of the row in datagrid on clicking the Delete LinkButton in Datagrid.
Please help.
ThanKs.
推荐答案
您可以通过在网格行的链接按钮的onClick上注入Javascript函数来执行以下操作.
要注入JS,您需要使用GridView的RowDataBound
,如下所示:
You can do the following by Injecting Javascript function on onClick of link button for a grid row.
For injecting JS, you need to useRowDataBound
of GridView, something like:
protected void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
DataControlRowType rtype = e.Row.RowType;
if (rtype == DataControlRowType.DataRow && rtype != DataControlRowType.Footer
&& rtype != DataControlRowType.Separator && rtype != DataControlRowType.Header
&& rtype != DataControlRowType.Pager)
{
// Highligh row on click of row
e.Row.Attributes.Add("onclick", "Highlight(this);");
}
}
针对任何事件(如鼠标悬停或链接按钮单击等)进行修改.
试试吧!
Modify it for any event like mouseover or link button click, etc.
Try!
这篇关于如何在“删除链接"按钮上更改Datagrid行的颜色在Datagrid中单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文