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
另两个,看样子也能行
<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();
}
}
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
好用吗?谁能分析一下它的设计模型,上手快不快?
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();
......