zoukankan      html  css  js  c++  java
  • 表格中点击获得行列的值、刷新页面

     //行号
    int row = ((GridViewRow)((Button)sender).NamingContainer).RowIndex;

     自定义列的显示(参考自csdn.net):

    <asp:TemplateField>  
    <ItemTemplate>
    <asp:Label ID="Label1" runat="server" />
    </ItemTemplate>
    </asp:TemplateField>

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    DataRowView drv = (DataRowView)e.Row.DataItem;
    Label lbl = (Label)e.Row.FindControl("Label1");
    switch (drv["字段名"].ToString())
    {
    case "1" :
    lbl.Text = "管理员";
    break;
    case "2":
    lbl.Text = "贵宾";
    break;

    }
    }
    }
    <asp:TemplateField>  
    <ItemTemplate>
    <asp:Label ID="Label1" runat="server" Text='<%# GetTitle(Eval("字段名")) %>'/>
    </ItemTemplate>
    </asp:TemplateField>

    public static string GetTitle(object type)
    {
    int n = -1;
    string title = string.Empty;
    if (int.TryParse(type.ToString(), out n)) //考虑到有空值的情况。
    {
    if (n == 1)
    title = "管理员";
    else if (n == 2)
    title = "贵宾";
    }
    else
    title = "UFO";

    return title;
    }



    Response.Write("<script>window.location.href=window.location.href;</script>"); 



  • 相关阅读:
    软件工程提问回顾与个人总结
    OO第二次单元总结
    OO第一次单元总结
    软件工程结对项目
    软件工程第一次阅读作业
    软件工程第0次个人作业
    结队作业
    软件工程第一次阅读作业
    软工第0次作业
    oo第四篇博客作业
  • 原文地址:https://www.cnblogs.com/oneivan/p/2296573.html
Copyright © 2011-2022 走看看