CopyPastehas never been so tasty!

FormView Control in ASP.NET 3.5

by anonymous

  • 0
  • 0
  • 0
112 views

 
FormView.aspx File code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FormView.aspx.cs" Inherits="FormView" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>FormView Control</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:FormView ID="FormView1" runat="server" 
            DataKeyNames="Product_ID" DataSourceID="SqlDataSource1" AllowPaging="True" 
            CellPadding="4" ForeColor="#333333">
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <RowStyle BackColor="#EFF3FB" />
        <EditItemTemplate>
            Product_ID:
            <asp:Label ID="Product_IDLabel1" runat="server" 
                Text='<%# Eval("Product_ID") %>' />
            <br />
            Product_Name:
            <asp:TextBox ID="Product_NameTextBox" runat="server" 
                Text='<%# Bind("Product_Name") %>' />
            <br />
            Supplier_ID:
            <asp:TextBox ID="Supplier_IDTextBox" runat="server" 
                Text='<%# Bind("Supplier_ID") %>' />
            <br />
            Color:
            <asp:TextBox ID="ColorTextBox" runat="server" Text='<%# Bind("Color") %>' />
            <br />
            column1:
            <asp:TextBox ID="column1TextBox" runat="server" Text='<%# Bind("column1") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <InsertItemTemplate>
            Product_ID:
            <asp:TextBox ID="Product_IDTextBox" runat="server" 
                Text='<%# Bind("Product_ID") %>' />
            <br />
            Product_Name:
            <asp:TextBox ID="Product_NameTextBox" runat="server" 
                Text='<%# Bind("Product_Name") %>' />
            <br />
            Supplier_ID:
            <asp:TextBox ID="Supplier_IDTextBox" runat="server" 
                Text='<%# Bind("Supplier_ID") %>' />
            <br />
            Color:
            <asp:TextBox ID="ColorTextBox" runat="server" Text='<%# Bind("Color") %>' />
            <br />
            column1:
            <asp:TextBox ID="column1TextBox" runat="server" Text='<%# Bind("column1") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </InsertItemTemplate>
        
        <ItemTemplate>
            Product_ID:
            <asp:Label ID="Product_IDLabel" runat="server" 
                Text='<%# Eval("Product_ID") %>' />
            <br />
            Product_Name:
            <asp:Label ID="Product_NameLabel" runat="server" 
                Text='<%# Bind("Product_Name") %>' />
            <br />
            Supplier_ID:
            <asp:Label ID="Supplier_IDLabel" runat="server" 
                Text='<%# Bind("Supplier_ID") %>' />
            <br />
            Color:
            <asp:Label ID="ColorLabel" runat="server" Text='<%# Bind("Color") %>' />
            <br />
            column1:
            <asp:Label ID="column1Label" runat="server" Text='<%# Bind("column1") %>' />
            <br />
           
        </ItemTemplate>
        
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#2461BF" />
        
    </asp:FormView>
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString3 %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString3.ProviderName %>" 
            SelectCommand="SELECT [Product ID] AS Product_ID, [Product Name] AS Product_Name, [Supplier ID] AS Supplier_ID, [Color], [Price (SRP)] AS column1 FROM [Product]">
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

Add A Comment: