Allen,
Below is the code for the displaying data page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
</script>
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ObjectDataSource ID="productDataSource" Runat="server"
TypeName="ProductDAL"
SelectMethod="GetProducts" EnablePaging="True"
SelectCountMethod="TotalNumberOfProducts" UpdateMethod="UpdateProduct">
<UpdateParameters>
<asp
arameter Name="ProductID" Type="Int32" />
<asp
arameter Name="productName" Type="String" />
<asp
arameter Name="unitPrice" Type="Decimal" />
<asp
arameter Name="unitsInStock" Type="Int32" />
</UpdateParameters>
</asp:ObjectDataSource>
<asp:GridView ID="GridView1" Runat="server"
DataSourceID="productDataSource"
AutoGenerateColumns="False" AllowPaging="True" BorderWidth="1px"
BackColor="White"
CellPadding="4" BorderStyle="None" BorderColor="#3366CC">
<FooterStyle ForeColor="#003399"
BackColor="#99CCCC"></FooterStyle>
<PagerStyle ForeColor="#003399" HorizontalAlign="Left"
BackColor="#99CCCC"></PagerStyle>
<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True"
BackColor="#003399"></HeaderStyle>
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID"
SortExpression="ProductID" />
<asp:BoundField DataField="ProductName"
HeaderText="ProductName" SortExpression="ProductName" />
<asp:BoundField DataField="QuantityPerUnit"
HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit" />
<asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice"
SortExpression="UnitPrice" />
<asp:BoundField DataField="UnitsInStock"
HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
</Columns>
<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True"
BackColor="#009999"></SelectedRowStyle>
<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>
</asp:GridView>
</div>
</form>
</body>
</html>
Below is the code for the editing folder folder:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
</script>
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="productsDataSource" Runat="server"
SelectCommand="SELECT dbo.Products.ProductID, dbo.Products.ProductName,
dbo.Products.CategoryID, dbo.Categories.CategoryName FROM dbo.Products INNER
JOIN dbo.Categories ON dbo.Products.CategoryID = dbo.Categories.CategoryID"
UpdateCommand="UPDATE [Products] SET [ProductName] =
@ProductName, [CategoryID] = @CategoryID WHERE [ProductID] =
@original_ProductID"
ConnectionString="<%$ ConnectionStrings:NWConnectionString %>">
<UpdateParameters>
<asp
arameter Type="String"
Name="ProductName"></asp
arameter>
<asp
arameter Type="Int32" Name="CategoryID"></asp
arameter>
<asp
arameter Name="original_ProductID"></asp
arameter>
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="categoryDataSource" Runat="server"
SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories] ORDER BY
[CategoryName]"
ConnectionString="<%$ ConnectionStrings:NWConnectionString %>">
</asp:SqlDataSource>
<asp:GridView ID="GridView1" Runat="server"
DataSourceID="productsDataSource" DataKeyNames="ProductID"
AutoGenerateColumns="False" AllowPaging="True" BorderWidth="1px"
BackColor="White"
CellPadding="3" BorderStyle="None" BorderColor="#CCCCCC">
<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
<PagerStyle ForeColor="#000066" HorizontalAlign="Left"
BackColor="White"></PagerStyle>
<HeaderStyle ForeColor="White" Font-Bold="True"
BackColor="#006699"></HeaderStyle>
<Columns>
<asp:CommandField ShowEditButton="True"></asp:CommandField>
<asp:BoundField ReadOnly="True" HeaderText="ProductID"
InsertVisible="False" DataField="ProductID"
SortExpression="ProductID">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="ProductName"
DataField="ProductName" SortExpression="ProductName"></asp:BoundField>
<asp:TemplateField SortExpression="CategoryName"
HeaderText="CategoryName"><EditItemTemplate>
<asp
ropDownList ID="DropDownList1" Runat="server"
DataSourceID="categoryDataSource"
DataTextField="CategoryName"
DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>'>
</asp
ropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label Runat="server" Text='<%#
Bind("CategoryName") %>' ID="Label1"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle ForeColor="White" Font-Bold="True"
BackColor="#669999"></SelectedRowStyle>
<RowStyle ForeColor="#000066"></RowStyle>
</asp:GridView>
</div>
</form>
</body>
</html>
Below is the code for the CustomizingEditingUI
%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
</script>
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="productsDataSource" Runat="server"
SelectCommand="SELECT dbo.Products.ProductID, dbo.Products.ProductName,
dbo.Products.CategoryID, dbo.Categories.CategoryName FROM dbo.Products INNER
JOIN dbo.Categories ON dbo.Products.CategoryID = dbo.Categories.CategoryID"
UpdateCommand="UPDATE [Products] SET [ProductName] =
@ProductName, [CategoryID] = @CategoryID WHERE [ProductID] =
@original_ProductID"
ConnectionString="<%$ ConnectionStrings:NWConnectionString %>">
<UpdateParameters>
<asp
arameter Type="String"
Name="ProductName"></asp
arameter>
<asp
arameter Type="Int32" Name="CategoryID"></asp
arameter>
<asp
arameter Name="original_ProductID"></asp
arameter>
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="categoryDataSource" Runat="server"
SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories] ORDER BY
[CategoryName]"
ConnectionString="<%$ ConnectionStrings:NWConnectionString %>">
</asp:SqlDataSource>
<asp:GridView ID="GridView1" Runat="server"
DataSourceID="productsDataSource" DataKeyNames="ProductID"
AutoGenerateColumns="False" AllowPaging="True" BorderWidth="1px"
BackColor="White"
CellPadding="3" BorderStyle="None" BorderColor="#CCCCCC">
<FooterStyle ForeColor="#000066" BackColor="White"></FooterStyle>
<PagerStyle ForeColor="#000066" HorizontalAlign="Left"
BackColor="White"></PagerStyle>
<HeaderStyle ForeColor="White" Font-Bold="True"
BackColor="#006699"></HeaderStyle>
<Columns>
<asp:CommandField ShowEditButton="True"></asp:CommandField>
<asp:BoundField ReadOnly="True" HeaderText="ProductID"
InsertVisible="False" DataField="ProductID"
SortExpression="ProductID">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="ProductName"
DataField="ProductName" SortExpression="ProductName"></asp:BoundField>
<asp:TemplateField SortExpression="CategoryName"
HeaderText="CategoryName"><EditItemTemplate>
<asp
ropDownList ID="DropDownList1" Runat="server"
DataSourceID="categoryDataSource"
DataTextField="CategoryName"
DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>'>
</asp
ropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label Runat="server" Text='<%#
Bind("CategoryName") %>' ID="Label1"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle ForeColor="White" Font-Bold="True"
BackColor="#669999"></SelectedRowStyle>
<RowStyle ForeColor="#000066"></RowStyle>
</asp:GridView>
</div>
</form>
</body>
</html>
Allen Chen said:
Hi Alex,
My name is Allen Chen. It's my pleasure to work with you on this issue.
First, could you clarify what do you mean by this?
Quote from Alex==================================================
However the product name field is
showing the same value.
==================================================
Could you provide your current aspx code and tell me your requirement in
detail?
Regards,
Allen Chen
Microsoft Online Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.