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());
                    }
    
                }
               
            }
  • 相关阅读:
    audio元素
    获取页面中出现次数最多的三个标签以及出现次数
    vue ssr(server side rendering)
    python_2 python的编码声明
    python_1 python的编译过程
    bugs
    isPrototypeOf和 instanceof 的区别
    WebStorm 配置Git
    MongoDB 副本集搭建
    获取结算样式 getComputedStyle-currentStyle
  • 原文地址:https://www.cnblogs.com/w6w6/p/10971999.html
Copyright © 2011-2022 走看看