<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="radA" %>
<%@ Register TagPrefix="radg" Namespace="Telerik.WebControls" Assembly="RadGrid.Net2" %>
<%@ Register TagPrefix="radm" Namespace="Telerik.WebControls" Assembly="RadMenu.Net2" %>
<%@ Register TagPrefix="sds" Namespace="SessionDS" Assembly="SessionDataSource" %>
<!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>Untitled Page</title>
</head>
<body style="margin: 0px;">
    <form id="form1" runat="server">
        <div>

            <script type="text/javascript">   
            function RowContextMenu(index, e)   
            {   
                document.getElementById("RadGridClickedRowIndex").value = index;   
                var menu = <%= RadMenu1.ClientID %>;   
                menu.Show(e);   
                   
                e.cancelBubble = true;   
                e.returnValue = false;   
  
                if (e.stopPropagation)   
                {   
                   e.stopPropagation();   
                   e.preventDefault();   
                }   
                this.SelectRow(this.Rows[index].Control, true);   
            }   
            </script>

            
            <radA:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true">
                <ajaxsettings>  
                <radA:AjaxSetting AjaxControlID="RadGrid1">   
                    <UpdatedControls>  
                        <radA:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="AjaxLoadingPanel1" />  
                    </UpdatedControls>  
                </radA:AjaxSetting>  
                <radA:AjaxSetting AjaxControlID="RadMenu1">   
                    <UpdatedControls>  
                        <radA:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="AjaxLoadingPanel1" />  
                        <radA:AjaxUpdatedControl ControlID="RadMenu1" />  
                    </UpdatedControls>  
                </radA:AjaxSetting>  
            </ajaxsettings>
            </radA:RadAjaxManager>
            <radA:AjaxLoadingPanel ID="AjaxLoadingPanel1" runat="server" Height="75px" Width="75px"
                Transparency="25">
                <asp:Image ID="Image1" runat="server" AlternateText="Loading..." ImageUrl="~/RadControls/Ajax/Skins/Default/Loading.gif" />
            </radA:AjaxLoadingPanel>
            <input type="hidden" id="RadGridClickedRowIndex" name="RadGridClickedRowIndex" />
            <p>
                Right-click the grid to open context menu.</p>
            <div style="margin-right: 20px;">
                <radg:RadGrid ID="RadGrid1" runat="server" Width="100%" GridLines="None" BorderWidth="0"
                    DataSourceID="SessionDataSource1" AllowAutomaticDeletes="true" AllowAutomaticInserts="true"
                    AllowAutomaticUpdates="true" Skin="Glassy" OnPreRender="RadGrid1_PreRender">
                    <mastertableview allowsorting="False" pagesize="10" allowpaging="True" width="100%"
                        datakeynames="ProductID" datasourceid="SessionDataSource1" editmode="InPlace">   
                    <Columns>  
                        <radg:GridEditCommandColumn UniqueName="EditCommandColumn" Visible="false" />  
                    </Columns>  
                </mastertableview>
                    <clientsettings>  
                    <ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents>  
                    <Selecting AllowRowSelect="true" />  
                </clientsettings>
                    <pagerstyle mode="NextPrevAndNumeric" />
                </radg:RadGrid>
            </div>
            <br />
            <sds:SessionDataSource ID="SessionDataSource1" runat="server" DataFile="~/Grid/Data/Access/NWind.mdb"
                SelectCommand="SELECT ProductID, ProductName,QuantityPerUnit,UnitPrice, UnitsInStock  FROM [Products]"
                DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = ?" InsertCommand="INSERT INTO Products(ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
                UpdateCommand="UPDATE [Products] SET [ProductName] = ?,[QuantityPerUnit] = ?, [UnitPrice] = ?, [UnitsInStock] = ? WHERE [ProductID] = ? AND [ProductName] = ? AND [QuantityPerUnit] = ? AND [UnitPrice] = ? AND [UnitsInStock] = ?"
                AutoIncrementFields="ProductID" OldValuesParameterFormatString="original_{0}"
                ConflictDetection="CompareAllValues">
                <deleteparameters>  
                <asp:Parameter Name="original_ProductID" Type="Int32" />  
            </deleteparameters>
                <updateparameters>  
                <asp:Parameter Name="ProductName" Type="String" />  
                <asp:Parameter Name="QuantityPerUnit" Type="String" />  
                <asp:Parameter Name="UnitPrice" Type="Decimal" />  
                <asp:Parameter Name="UnitsInStock" Type="Int16" />  
                <asp:Parameter Name="original_ProductID" Type="Int32" />  
                <asp:Parameter Name="original_ProductName" Type="String" />  
                <asp:Parameter Name="original_QuantityPerUnit" Type="String" />  
                <asp:Parameter Name="original_UnitPrice" Type="Decimal" />  
                <asp:Parameter Name="original_UnitsInStock" Type="Int16" />  
            </updateparameters>
                <insertparameters>  
                <asp:Parameter Name="ProductName" Type="String" />  
                <asp:Parameter Name="SupplierID" Type="Int32" />  
                <asp:Parameter Name="CategoryID" Type="Int32" />  
                <asp:Parameter Name="QuantityPerUnit" Type="String" />  
                <asp:Parameter Name="UnitPrice" Type="Decimal" />  
                <asp:Parameter Name="UnitsInStock" Type="Int16" />  
                <asp:Parameter Name="UnitsOnOrder" Type="Int16" />  
                <asp:Parameter Name="ReorderLevel" Type="Int16" />  
                <asp:Parameter Name="Discontinued" Type="Boolean" />  
            </insertparameters>
            </sds:SessionDataSource>
            <radm:RadMenu ID="RadMenu1" IsContext="True" runat="server" 
                Skin="Outlook" OnItemClick="RadMenu1_ItemClick"
                ContextMenuElementID="none">
                <items>  
                <radm:RadMenuItem Text="Add" />  
                <radm:RadMenuItem Text="Edit" />  
                <radm:RadMenuItem Text="Delete" />  
            </items>
            </radm:RadMenu>
            
        </div>
    </form>
</body>
</html>
