文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>GridView中的超级链接HyperLinkField

GridView中的超级链接HyperLinkField

时间:2010-08-23  来源:叮当小马

第一种方法:

<asp:HyperLinkField DataNavigateUrlFields="stu"
                    DataNavigateUrlFormatString="xx.aspx?stu={0}"
                     HeaderText="更新" Text="更新" >
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
</asp:HyperLinkField>

DataNavigateUrlFields,也就是gridview中的字段,DataNavigateUrlFormatString,就可以对字符串进行编辑

DataNavigateUrlFields,也就可以传递多个参数

第二种方法

 <asp:TemplateField HeaderText="更新" Visible="true" HeaderStyle-HorizontalAlign = "Center"  ItemStyle-HorizontalAlign="Center">
         <ItemTemplate>
               <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='' Text="更新"></asp:HyperLink>
         </ItemTemplate>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>

TemplateField 模板列要在RowDataBound进行绑定

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
     {
       if (e.Row.RowType == DataControlRowType.DataRow)
         {
             //模板列

             ((HyperLink)e.Row.Cells[10].FindControl("HyperLink1")).NavigateUrl = "xx.aspx?stu=" + Server.UrlEncode(e.Row.Cells[0].Text.Trim());

         }

     }

相关阅读 更多 +
排行榜 更多 +
泡龙大闯关安卓版

泡龙大闯关安卓版

冒险解谜 下载
割草派对安卓版

割草派对安卓版

飞行射击 下载
堡垒攻防战安卓版

堡垒攻防战安卓版

飞行射击 下载