首页 新闻 赞助 找找看

怎么在gridview 的列的名称做一个连接?鼠标经过时连接的名称颜色改变?求代码。

0
[已解决问题] 解决于 2011-12-19 22:54

像这样的....

lqps的主页 lqps | 初学一级 | 园豆:44
提问于:2011-12-10 17:05
< >
分享
最佳答案
0

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";

sunlary | 小虾三级 |园豆:934 | 2011-12-11 14:58
其他回答(1)
0
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;}
小小刀 | 园豆:1991 (小虾三级) | 2011-12-10 19:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册