用的是AccessDataSource,语句如下:
<asp:AccessDataSource ID="AccessDSProduct" runat="server" DataFile="~/App_Data/webDB.mdb"
DeleteCommand="DELETE FROM products WHERE (ProductID = ?)"
InsertCommand="INSERT INTO products(ProductID, ProductName, DescriptionSc, ImageName, ImageFile, UpData) VALUES (,,,,,)"
SelectCommand="SELECT products.ProductID, products.ProductName, products.TypeID AS Expr1, products.BrandID AS Expr2, products.Description, products.DescriptionSc, products.ImageName, products.ImageFile, products.Favorable, products.UpData, Types.TypeID, Types.TypeName, Types.TypeNameSc, Brands.BrandID, Brands.BrandName, Brands.BrandNameSc FROM ((products INNER JOIN Types ON products.TypeID = Types.TypeID) INNER JOIN Brands ON products.BrandID = Brands.BrandID) WHERE (products.TypeID = ?) AND (products.BrandID = ?)"
UpdateCommand="UPDATE products SET products.ProductName = ?, products.Description = ?, products.DescriptionSc = ?, products.ImageName = ?, products.UpData = ? WHERE (products.ProductID = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlType" Name="?" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="ddlBrand" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:AccessDataSource>下面是GridView:<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="AccessDSProduct" DataMember="DefaultView">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="编号" InsertVisible="False"
ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="产品名称" SortExpression="ProductName" />
<asp:BoundField DataField="Description" HeaderText="英文描述" SortExpression="Description" />
<asp:BoundField DataField="DescriptionSc" HeaderText="中文描述" SortExpression="DescriptionSc" />
<asp:BoundField DataField="ImageName" HeaderText="图片名称" SortExpression="ImageName" />
<asp:BoundField DataField="UpData" HeaderText="更新日期" SortExpression="UpData" DataFormatString="{0:d}" />
<asp:CommandField ShowSelectButton="True" HeaderText="操作" ShowDeleteButton="True" ShowEditButton="True" SelectText="预览" />
</Columns>
<FooterStyle BackColor="LightSlateGray" ForeColor="Black" />
<SelectedRowStyle BackColor="#9471DE" ForeColor="White" Font-Bold="True" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="LightSlateGray" Font-Bold="True" ForeColor="White" Height="40px" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" Wrap="True" />
<PagerSettings FirstPageText="&gt;&gt;" Mode="NumericFirstLast" />
</asp:GridView>以上这样时的数据操作都是正常的.
当我加入另一表的数据时,操作就无效了,郁闷了很久!
加入一列:
<asp:BoundField DataField="BrandName" HeaderText="BrandName" SortExpression="BrandName" />哪位高手可以解答一下这个问题是怎么回事??
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货