zoukankan      html  css  js  c++  java
  • ASP.NET中常用重置数据的方法

    aspx:

    <asp:Repeater ID="rptProlist" runat="server" onitemdatabound="rptProlist_ItemDataBound">
                <HeaderTemplate>
                    <table border="0" class="infolist" cellpadding="0" cellspacing="0">
                        <thead>
                            <tr>
                                <th width="10%">开始日期</th>
                                <th width="7%">创建人</th>
                                <th width="7%">负责人</th>
                                <th width="20%">参与人</th>
                            </tr>
                        </thead>
                </HeaderTemplate>
                <ItemTemplate>
                    <tbody>
                        <tr>
                            <td><%#Eval("StartDate","{0:yyyy-MM-dd}")%></td>
                            <td><%#returnUserRealName(Eval("ProjectCreater").ToString())%></td>
                            <td><%#returnUserRealName(Eval("ProjectPrincipal").ToString())%></td>
                            <td><asp:Label ID="lbPlayers" runat="server" Text='<%#Eval("ProjectPlayers") %>'></asp:Label></td>
                        </tr>
                    </tbody>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>

    aspx.cs:

         public string returnUserRealName(string data)
            {
                string[] ss = data.Split(',');
                string str = "";
                foreach (string item in ss)
                {
                    str += new PM.BLL.tb_User().GetModel(int.Parse(item)).UserRealName + ",";
                }
                str = str.Substring(0, str.Length - 1);
                return str;
            }
            protected void rptProlist_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                {
                    Label lb = (Label)e.Item.FindControl("lbPlayers");
                    string[] ss = lb.Text.Split(',');
                    lb.Text = "";//清空重置之前的数据
                    foreach (string item in ss)
                    {
                        lb.Text += new PM.BLL.tb_User().GetModel(int.Parse(item)).UserRealName + ",";
                    }
                    lb.Text = lb.Text.Substring(0, lb.Text.Length - 1);
                }
            }

  • 相关阅读:
    [转]mysql的查询、子查询及连接查询
    [转]Mysql之Union用法
    [转]Mysql Join语法解析与性能分析
    【转】mysql中select用法
    [转]mysql update操作
    【转】mysql INSERT的用法
    框架:NHibernate学习目录
    NET基础篇——Entity Framework 数据转换层通用类
    MVC5 + EF6 + Bootstrap3
    MVC5+EF6 入门完整教程
  • 原文地址:https://www.cnblogs.com/liuswi/p/3615381.html
Copyright © 2011-2022 走看看