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());
                    }
    
                }
               
            }
  • 相关阅读:
    Epoll技术深入学习
    nginx
    epoll案例
    Linux网络编程初步
    链表快速排序(已通过ACM在线评测)
    C++内存管理
    c++11并发语法初步
    数据库与SQL优化笔记(一)
    C++面向对象模型(虚表与虚表指针)
    c++的一些杂项
  • 原文地址:https://www.cnblogs.com/w6w6/p/10971999.html
Copyright © 2011-2022 走看看