首页 > Web开发 > 详细

ASP.NET中常用重置数据的方法

时间:2014-03-23 10:38:12      阅读:453      评论:0      收藏:0      [点我收藏+]

aspx:

bubuko.com,布布扣
<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>
bubuko.com,布布扣

aspx.cs:

bubuko.com,布布扣
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);
            }
        }
bubuko.com,布布扣

bubuko.com,布布扣

bubuko.com,布布扣

ASP.NET中常用重置数据的方法,布布扣,bubuko.com

ASP.NET中常用重置数据的方法

原文:http://www.cnblogs.com/liuswi/p/3615381.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!