如题:    用IList 还是 ArrayList 或者 List   想给DataList或GridView绑定,不明白如何使用?    希望能给出具体的例子。

解决方案 »

  1.   

    ArrayList 应该是可以的
    另两个,看样子也能行
      

  2.   

    http://blog.csdn.net/weifan_1/archive/2007/10/08/1815281.aspx
      

  3.   

    ArrayList应该可以直接作为数据源进行帮定
      

  4.   


        <asp:GridView ID="GV1" runat="server" OnRowDataBound="GV1_RowDataBound">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Literal ID="litStr" runat="server"></asp:Literal>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    CS:    protected void Page_Load(object sender, EventArgs e)
        {
            ArrayList al1 = new ArrayList();
            al1.Add("111");
            al1.Add("222");
            al1.Add("333");
            this.GV1.DataSource = al1;
            this.GV1.DataBind();
        }
        protected void GV1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Literal litstr = (Literal)e.Row.FindControl("litStr");
                litstr.Text = ((ArrayList)GV1.DataSource)[e.Row.RowIndex].ToString();
            }
        }
      

  5.   

    List吧,用泛形不用装箱拆箱.和Dataset用法一样,把集合中对象的属性名当成数据库中的字段名
      

  6.   

    读出来的数据,怎样放入ArrayList?是否有效率问题?
      

  7.   

     Public Class personal        Private _personalName As String        Public Property personalName() As String
                Get
                    Return _personalName
                End Get
                Set(ByVal value As String)
                    _personalName = value
                End Set
            End Property        Sub New(ByVal personalName As String)
                Me._personalName = personalName
            End Sub    End Class    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load'gv 是 gridview        gv.DataSource = createDataSource()
            gv.DataBind()    End Sub    Public Function createDataSource() As System.Collections.Generic.List(Of personal)        Dim personals As New System.Collections.Generic.List(Of personal)
            personals.Add(New personal("asp.net"))
            personals.Add(New personal("vb.net"))
            Return personals    End Function
      

  8.   

    另外看到很多人用Nhibernate?
    好用吗?谁能分析一下它的设计模型,上手快不快?
      

  9.   

    哪里有Nhibernate应用的比较好的例子?
      

  10.   

    用IList<T>泛型集合接口
      

  11.   

    VB的泛型用圆括号,还要加Of,不爽
      

  12.   

    建议使用IList<T>int pageSize = 10;
    ISort sort = null;
    long totalRecords;       
    //调用方法获取数据集合
     IList<DesignProxy> designProxyList = service.QueryDesignProxyList(pageIndex, filterString.ToString(), sort, out totalRecords);
    this.gvwResult.DataSource = designProxyList;
    this.PalResult.Visible = true;
    this.gvwResult.DataBind();  
    ......