六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 9|回复: 0

gridview超链接列链接方法 (转)

[复制链接]

升级  0.95%

325

主题

325

主题

325

主题

探花

Rank: 6Rank: 6

积分
1019
 楼主| 发表于 2013-1-29 09:22:11 | 显示全部楼层 |阅读模式
<asp:GridViewID="grdSent"runat="server"AllowPaging="True"AutoGenerateColumns="False"OnPageIndexChanging="grdSent_PageIndexChanging">
<Columns>
<asp:CommandFieldShowDeleteButton="True"/>
<asp:BoundFieldDataField="uniqueID"HeaderText="uniqueID"Visible="False"/>
<asp:HyperLinkFieldDataNavigateUrlFields="uniqueID"DataNavigateUrlFormatString="~/BBS/fckeditor.aspx?fck={0}"DataTextField="subject"HeaderText="主题"/>
<asp:BoundFieldDataField="mailFrom"HeaderText="发件人"/>
<asp:BoundFieldDataField="sendTime"HeaderText="发送时间"/>
</Columns>
</asp:GridView>

带多个参数:
<asp:HyperLinkFieldDataNavigateUrlFields="parentid,id"Text="下级目录"DataNavigateUrlFormatString="productchildren.aspx?pid={0}&id={1}"HeaderText="查看下级目录"/>



另一种后台编写方法:[Vegas原创]
<asp:TemplateFieldHeaderText="表单名称">
<ItemTemplate>
<asp:HyperLinkID="HyperLink1"runat="server"Text='<%#Eval("FORM_NAME")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
protectedvoidGridView1_RowDataBound(objectsender,GridViewRowEventArgse)
{
//在不可见之前做很多事情~~~~

if(e.Row.RowType==DataControlRowType.DataRow)
{
//链接~
((HyperLink)e.Row.Cells[1].FindControl("HyperLink1")).NavigateUrl=string.Format("javascript:voidwindow.open('http://DTSFLOWER/module/mailroute.aspx?FORM_KIND={0}&FORM_NO={1}&FORM_APPROVE_ID={2}&LOGON_ID={3}&MAIL_TYPE={4}');",
e.Row.Cells[
2].Text,e.Row.Cells[0].Text,e.Row.Cells[3].Text,e.Row.Cells[4].Text,e.Row.Cells[5].Text);
//小提示~
e.Row.Cells[1].ToolTip="表单号:"+e.Row.Cells[0].Text;

//VISIBLE=FALSE~~~
for(inti=0;i<e.Row.Cells.Count;i++)
{
if(i!=1)
{
e.Row.Cells.Visible
=false;
}
}

}
}

<!--XN_AntiSpam_Robot 2009-06-16-->
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表