<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Editing Data using Templated Columns</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="productsSource" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:AdventureWorks %>"
SelectCommand="Select ProductID, Name, ProductNumber, DaysToManufacture, SellStartDate, ReorderPoint from Production.Product"
UpdateCommand="Update Production.Product Set ReorderPoint = @ReorderPoint Where ProductID = @ProductID">
</asp:SqlDataSource>
<asp:GridView ID="gridProducts" runat="server" DataSourceID="productsSource"
AutoGenerateColumns="False" DataKeyNames="ProductID">
<Columns>
<asp:CommandField ShowEditButton="true" />
<asp:TemplateField HeaderText="Products">
<ItemTemplate>
<%# Eval("ProductID") %> -
<%# Eval("Name") %>
Product Number: <%# Eval("ProductNumber") %><br />
Reorder Point:<%# Eval("ReorderPoint") %><br />
</small>
</ItemTemplate>
<EditItemTemplate>
<%# Eval("ProductID") %> -
<%# Eval("Name") %>
Product Number: <%# Eval("ProductNumber") %><br />
Reorder Point:<asp:TextBox Text='<%# Bind("ReorderPoint") %>' runat="server" id="textBox"/>
</small>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
|