【发布时间】:2012-10-09 03:15:39
【问题描述】:
我的代码中有一个List<string[]> items 列表,其中填充了字符串数组。在 ASPX 页面上,我添加了一个新的网格视图控件:
<asp:GridView ID="ProductList" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ProductID" EnableViewState="False">
<Columns>
<asp:BoundField DataField="ProductName" HeaderText="Product" SortExpression="ProductName" />
<asp:BoundField DataField="CategoryName" HeaderText="Category" ReadOnly="True" SortExpression="CategoryName" />
<asp:BoundField DataField="SupplierName" HeaderText="Supplier" ReadOnly="True" SortExpression="SupplierName" />
<asp:BoundField DataField="UnitPrice" DataFormatString="{0:C}" HeaderText="Price" HtmlEncode="False" SortExpression="UnitPrice" />
<asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" />
</Columns>
</asp:GridView>
我知道我应该以类似于以下的方式为网格视图指定 DataSourceID 属性:
<asp:GridView ... `DataSourceID="ObjectDataSource1" ... >
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetProducts" TypeName="ProductsBLL">
</asp:ObjectDataSource>
但是,我不知道OldValuesParameterFormatString、SelectMethod 和TypeName 属性代表什么。另外,我没有要绑定的数据库,我只有一个名为items 的字符串数组列表。你能帮我填充网格视图吗?根本不需要通过绑定来完成。谢谢!
【问题讨论】:
标签: asp.net data-binding gridview binding populate