強大的asp.net 綁定組件

來源:互聯網
上載者:User
asp.net 的資料集合Binder 方法 DataBinder.Eval 不好用,不支援子實體綁定,不支援枚舉轉義綁定等等,總之不是很好用,只好自己豐衣足食,

組件下載:http://files.cnblogs.com/zhouyongguo/testLogon.rar

頁面html代碼式:<table border=1>
                <tr>
                    <td>名稱</td>
                    <td>審核</td>
                    <td>日期</td>
                    <td>其他</td>
                </tr>
                <asp:repeater id="Repeater1" runat="server">
                    <ItemTemplate>
                        <tr>
                            <td><%#Great.MyBinder.Eval(Container.DataItem,"Title")%></td>
                            <td><%#Great.MyBinder.EvealEnum(Container.DataItem,"IsAuditing",new string[]{"審核","未審核"})%></td>
                            <td><%#Great.MyBinder.EvalDate(Container.DataItem,"CreateDate",true)%></td>
                            <td><%#Great.MyBinder.Eval(Container.DataItem,"file.Name")%></td>
                        </tr>
                    </ItemTemplate>
                </asp:repeater>
            </table>

file.Name 可以一直點下去 如:file.Name...,可以綁定私人欄位,枚舉 布爾可以轉義

代碼: 1private void Page_Load(object sender, System.EventArgs e)
 2        {
 3            this.Repeater1.DataSource=GetList();
 4            this.Repeater1.DataBind();
 5        }
 6
 7        private ArrayList GetList()
 8        {
 9            System.Collections.ArrayList list=new ArrayList();
10            Doc doc=new Doc(System.DateTime.Now);
11            doc.Title="計劃";
12            doc.file=new File("福建");
13            list.Add(doc);
14
15            Doc doc1=new Doc(new DateTime(2004,4,6));
16            doc1.Title="報告";
17            doc1.IsAuditing=true;
18            doc1.file=new File("北京");
19            list.Add(doc1);
20            return list;
21            
22        }

實體:

public class Doc
    {
        string _title="";
        public string Title
        {
            get{return this._title;}
            set{this._title=value;}
        }

        public File file;

        private System.DateTime CreateDate=System.DateTime.Now;

        public bool IsAuditing=false;
        public Doc()
        {            
        }

        public Doc(System.DateTime createDate)
        {
            CreateDate=createDate;
        }
    }

    public class File
    {
        private string Name="";
        public File(string name)
        {
            this.Name=name;

        }
    }
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.