<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="DefaultVB" %>

<%@ Register TagPrefix="radg" Namespace="Telerik.WebControls" Assembly="RadGrid.Net2" %>
<%@ Register TagPrefix="radw" Namespace="Telerik.WebControls" Assembly="RadWindow.Net2" %>
<!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="Window Editing For RadGrid"></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <script type="text/javascript">
			function ShowEditForm(id, rowIndex)
			{
                var grid = window["<%= RadGrid1.ClientID %>"];
                
                var rowControl = grid.MasterTableView.Rows[rowIndex].Control;                
                grid.MasterTableView.SelectRow(rowControl, true);
                			
				window.radopen("EditForm.aspx?EmployeeId=" + id, "UserListDialog");
				return false; 
			}
            function ShowInsertForm()
            {
               window.radopen("InsertForm.aspx", "UserListDialog");
               return false;
            }
			function refreshGrid(arg)
			{
			    if(!arg)
			    {
				  window["<%= RadGrid1.ClientID %>"].AjaxRequest('<%= RadGrid1.UniqueID %>', 'Rebind');
				}
				else
				{
				  window["<%= RadGrid1.ClientID %>"].AjaxRequest('<%= RadGrid1.UniqueID %>', 'RebindAndNavigate');
				}
			}
            </script>

            <radg:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" EnableAJAX="True" OnItemCreated="RadGrid1_ItemCreated"
                Width="97%" Skin="Glassy" DataSourceID="AccessDataSource1">
                <PagerStyle Mode="NumericPages" />
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="EmployeeID" Width="100%"
                    CommandItemDisplay="Top" PageSize="5">
                    <Columns>
                        <radg:GridBoundColumn DataField="EmployeeID" DataType="System.Int32" HeaderText="EmployeeID"
                            ReadOnly="True" SortExpression="EmployeeID" UniqueName="EmployeeID">
                        </radg:GridBoundColumn>
                        <radg:GridBoundColumn DataField="LastName" HeaderText="LastName" SortExpression="LastName"
                            UniqueName="LastName">
                        </radg:GridBoundColumn>
                        <radg:GridBoundColumn DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName"
                            UniqueName="FirstName">
                        </radg:GridBoundColumn>
                        <radg:GridBoundColumn DataField="Title" HeaderText="Title" SortExpression="Title"
                            UniqueName="Title">
                        </radg:GridBoundColumn>
                        <radg:GridTemplateColumn UniqueName="TemplateEditColumn">
                            <ItemTemplate>
                                <asp:HyperLink ID="EditLink" runat="server" Text="Edit"></asp:HyperLink>
                            </ItemTemplate>
                        </radg:GridTemplateColumn>
                    </Columns>
                    <CommandItemTemplate>
                        <asp:Image ID="AddRecord1" runat="server" ImageUrl="~/RadControls/Grid/Skins/Default/AddRecord.gif"
                            AlternateText="Add Record" />
                        <a href="#" onclick="return ShowInsertForm();">Add New Record</a>
                    </CommandItemTemplate>
                </MasterTableView>
                <ClientSettings>
                    <Selecting AllowRowSelect="true" />
                </ClientSettings>
            </radg:RadGrid>
            <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/NWind.mdb"
                SelectCommand="SELECT [EmployeeID], [FirstName], [LastName], [Title] FROM [Employees]">
            </asp:AccessDataSource>
            <radw:RadWindowManager ID="RadWindowManager1" runat="server">
                <Windows>
                    <radw:RadWindow ID="UserListDialog" runat="server" Title="User List Dialog" Height="400px"
                        Width="300px" Left="150px" ReloadOnShow="true" Modal="true" Skin="Office2007" />
                </Windows>
            </radw:RadWindowManager>
        </div>
    </form>
</body>
</html>
