gridview加模板列
<asp:TemplateField HeaderText="绑定">
<ItemTemplate>
<asp:LinkButton id="lbId" OnClientClick="ShowEditDPSN(this)" runat="server"
CommandName="Transfer" ImageUrl="~/images/1.gif" Text='<%# DataBinder.Eval(Container, "DataItem.DPAuthorName") %>' >
</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
js方法
function ShowEditDPSN(obj)
{
var strDPSN=obj.value;
var strMsg= window.showModalDialog("EditDPSnLimite.aspx?intValue=1&DPSNInfo="+escape(strDPSN),"","dialogHeight:300px; dialogWidth:450px; status:no; help:no; scroll:no");
}
.cs代码
在gridview 的RowDataBound事件中操作
LinkButton lb = (LinkButton)((System.Web.UI.WebControls.TableRow)(gv)).Cells[5].FindControl("lbID");
lb.Attributes.Add("value", strName);
strName是超链接传得参数
鼠标事件
GridView1_RowDataBound事件中
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F1F0F1'");
////当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
////设置悬浮鼠标指针形状为"小手"
e.Row.Attributes["style"] = "Cursor:hand";
a:link {display:block; color:#000; text-decoration: none;}
a:visited {display:block; color:#000; text-decoration: none;}
a:hover {display:block; color:#FFF; text-decoration:none;}
a:active {display:block; color:#FFF; text-decoration:none;}