我会尝试快速解释我的问题,并提供必要的数据,希望能在这个问题上得到一些帮助......这就是我想在ASP.net中构建的内容:
它基本上只是一个产品列表和每个月销售的数量......到目前为止,我已经想出了如何使用asp.net及其#34; BoundField"属性创建第一条记录:
我的查询如下:
SELECT year, product_id, t.id AS id,
t.standardcase AS standardcase,
p.shortname AS shortname
FROM transactions t, products p
WHERE year = 2009 AND product_id = p.ID AND market_id = 1 AND product_id = 1"
我的表格结构如下:
CREATE TABLE [dbo].[products](
[ID] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](30) NOT NULL,
[shortname] [varchar](15) NULL,
[SKU] [varchar](50) NULL,
[ml] [smallint] NOT NULL,
[category]
[varchar](50) NOT NULL,
[status] [bit] NOT NULL)
CREATE TABLE [dbo].[transactions](
[ID] [int] IDENTITY(1,1) NOT NULL,
[market_id] [int] NOT NULL,
[product_id] [int] NOT NULL,
[month] [tinyint] NOT NULL,
[year] [smallint] NOT NULL,
[standardcase] [int] NOT NULL,
[ninelitercase] [int] NOT NULL,
[userid] [nchar](10) NULL,
[timestamp] [nchar](10) NULL)
因此,对于某一年,需要显示/编辑120个数量......
以下是我用于数据绑定的代码:
<%@ Page Language="VB" %>
<html>
<head id="Head1" runat="server">
<title>Updating Data Using GridView</title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" AllowSorting="false" AllowPaging="false" Runat="server"
DataSourceID="SqlDataSource1" AutoGenerateEditButton="true" DataKeyNames="id"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField ReadOnly="true" HeaderText="Products" DataField="shortname" SortExpression="shortname" />
<asp:BoundField HeaderText="January" DataField="standardcase" SortExpression="standardcase" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT year, product_id, t.id as id, t.standardcase as standardcase, p.shortname as shortname from transactions t, products p where year = 2009 and product_id = p.ID and market_id = 1 and product_id = 1 and month = 1"
UpdateCommand=""
ConnectionString="<%$ ConnectionStrings:myConnectionString %>" />
</form>
</body>
</html>
任何人都可以了解如何使用BoundField来构建&#34;跨越顶峰的几个月?每个字段都有一个唯一的ID,以便于更新,但我只需要弄清楚如何在ASP.net中轻松填充其余字段?