<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>


<!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 Example</title>
</head>
<body>
    <form id="form2" runat="server">

        <h3>FormView Example</h3>
        <asp:ScriptManager runat="server" />
        <asp:FormView ID="EmployeeFormView"
            DataSourceID="EmployeeSource"
            AllowPaging="true"
            DataKeyNames="EmployeeID"
            EmptyDataText="No employees found."
            runat="server">

            <RowStyle BackColor="LightGreen"
                Wrap="false" />
            <EditRowStyle BackColor="LightBlue"
                Wrap="false" />

            <ItemTemplate>
                <table>
                    <tr>
                        <td>
                            <b>Name:</b>
                        </td>
                        <td>
                            <%# Eval("FirstName") %> <%# Eval("LastName") %>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <b>Title:</b>
                        </td>
                        <td>
                            <%# Eval("Title") %>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:LinkButton ID="Edit"
                                Text="Edit"
                                CommandName="Edit"
                                runat="server" />
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
            <EditItemTemplate>
                <table>
                    <tr>
                        <td>
                            <b>Name:</b>
                        </td>
                        <td>
                            <telerik:RadTextBox ID="FirstNameUpdateTextBox"
                                Text='<%# Bind("FirstName") %>'
                                runat="server" />
                            <telerik:RadDropDownList ID="LastNameUpdateTextBox"
                                runat="server" DataSourceID="EmployeeSource"
                                DataTextField="LastName"
                                DataValueField="LastName"
                                SelectedValue='<%# Bind("LastName") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <b>Title:</b>
                        </td>
                        <td>
                            <asp:TextBox ID="TitleUpdateTextBox"
                                Text='<%# Bind("Title") %>'
                                runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:LinkButton ID="UpdateButton"
                                Text="Update"
                                CommandName="Update"
                                runat="server" />
                            <asp:LinkButton ID="CancelButton"
                                Text="Cancel"
                                CommandName="Cancel"
                                runat="server" />
                        </td>
                    </tr>
                </table>
            </EditItemTemplate>

        </asp:FormView>

        <!-- This example uses Microsoft SQL Server and connects  -->
        <!-- to the Northwind sample database. Use an ASP.NET     -->
        <!-- expression to retrieve the connection string value   -->
        <!-- from the Web.config file.                            -->
        <asp:SqlDataSource ID="EmployeeSource"
            SelectCommand="Select [EmployeeID], [LastName], [FirstName], [Title] From [Employees]"
            UpdateCommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title Where [EmployeeID]=@EmployeeID"
            ConnectionString="<%$ ConnectionStrings:NorthWindConnection%>"
            runat="server">
            <InsertParameters>
                <asp:Parameter Name="EmployeeID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="LastName" Type="String"></asp:Parameter>
                <asp:Parameter Name="FirstName" Type="String"></asp:Parameter>
                <asp:Parameter Name="Title" Type="String"></asp:Parameter>
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="EmployeeID" Type="Int32"></asp:Parameter>
                <asp:Parameter Name="LastName" Type="String"></asp:Parameter>
                <asp:Parameter Name="FirstName" Type="String"></asp:Parameter>
                <asp:Parameter Name="Title" Type="String"></asp:Parameter>
            </UpdateParameters>
        </asp:SqlDataSource>

    </form>
</body>
</html>
