zoukankan      html  css  js  c++  java
  • gridview HyperLink 动态改变

    1、首先在在gridview 的column 列新增一个HyperLink 列

                        <asp:TemplateField HeaderText="合同信息" >
                                     <ItemTemplate>
                       
                                    <asp:HyperLink ID="HyperLink1"  runat="server"  ></asp:HyperLink> 
                            </ItemTemplate>
                                   <HeaderStyle HorizontalAlign="Center" Width="50px" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>

    2、在 GridView1_RowDataBound 事件中进行动态管理代码如下

    数据库中增加一个state ,新增一个state列来判断是新增还是修改

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    DataRowView drv = (DataRowView)e.Row.DataItem;
                    if (drv.Row["ywhetong"].ToString() == "1")
                    {
                        ((HyperLink)e.Row.Cells[5].FindControl("HyperLink1")).Text = "管理";
                        ((HyperLink)e.Row.Cells[5].FindControl("HyperLink1")).NavigateUrl = string.Format("hetongNowEdit.aspx?projectid={0}", drv.Row["projectid"].ToString());
                    }
    
                    else
                    {
                        ((HyperLink)e.Row.Cells[5].FindControl("HyperLink1")).Text = "新建合同";
                        ((HyperLink)e.Row.Cells[5].FindControl("HyperLink1")).NavigateUrl = string.Format("hetongNewAdd.aspx?id={0}", drv.Row["id"].ToString());
                    }
    
                }
               
            }
  • 相关阅读:
    Java原始数据类型
    Java文件教程
    Java.util.ArrayDeque类
    Java 简介
    面向对象的程序设计
    Java8默认方法
    divide方法
    java.lang.Boolean.compareTo()方法实例
    AWT Button类
    Java的核心优势
  • 原文地址:https://www.cnblogs.com/w6w6/p/10971999.html
Copyright © 2011-2022 走看看