<%@ Page Title="Products" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="GridViewAddEdit_Products.aspx.vb" Inherits="Northwind45.GridViewAddEdit_Products" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server"> <%: Styles.Render("~/Styles/jquery.tooltip.css") %> <%: Scripts.Render("~/Scripts/jquery.tooltip.min.js") %> <%: Scripts.Render("~/Scripts/jquery.validate.min.js") %> <%: Scripts.Render("~/Scripts/jquery.metadata.min.js") %> <%: Scripts.Render("~/Scripts/gridview-addrecord-script.js") %> <script type="text/javascript"> var addEditTitle = "Products"; var urlAndMethod = "GridViewAddEdit_Products.aspx/GetProducts"; $(function () { InitializeAddEditRecord(); InitializeToolTip(); InitializeValidation(); }); function clearFields() { $("#<%=TxtProductID.ClientID %>").attr('disabled', false); $("#<%=TxtProductName.ClientID %>").val(''); $("#<%=DdlSupplierID.ClientID %>").val(''); $("#<%=DdlCategoryID.ClientID %>").val(''); $("#<%=TxtQuantityPerUnit.ClientID %>").val(''); $("#<%=TxtUnitPrice.ClientID %>").val(''); $("#<%=TxtUnitsInStock.ClientID %>").val(''); $("#<%=TxtUnitsOnOrder.ClientID %>").val(''); $("#<%=TxtReorderLevel.ClientID %>").val(''); $("#<%=CbxDiscontinued.ClientID %>").attr('checked', false); } function assignRetrievedItems(msg) { $("#<%=HfldProductID.ClientID %>").val(msg.d.ProductID); $("#<%=TxtProductID.ClientID %>").attr('disabled', true); $("#<%=TxtProductID.ClientID %>").val(ConvertNullToString(msg.d.ProductID)); $("#<%=TxtProductName.ClientID %>").val(ConvertNullToString(msg.d.ProductName)); $("#<%=DdlSupplierID.ClientID %>").val(ConvertNullToString(msg.d.SupplierID)); $("#<%=DdlCategoryID.ClientID %>").val(ConvertNullToString(msg.d.CategoryID)); $("#<%=TxtQuantityPerUnit.ClientID %>").val(ConvertNullToString(msg.d.QuantityPerUnit)); $("#<%=TxtUnitPrice.ClientID %>").val(ConvertNullToString(msg.d.UnitPrice)); $("#<%=TxtUnitsInStock.ClientID %>").val(ConvertNullToString(msg.d.UnitsInStock)); $("#<%=TxtUnitsOnOrder.ClientID %>").val(ConvertNullToString(msg.d.UnitsOnOrder)); $("#<%=TxtReorderLevel.ClientID %>").val(ConvertNullToString(msg.d.ReorderLevel)); $("#<%=CbxDiscontinued.ClientID %>").attr('checked', ConvertNullToFalse(msg.d.Discontinued)); } </script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> <div id="deleteConfirmationDialog"></div> <div id="errorDialog" title="An error occured during item deletion!"></div> <asp:HyperLink ID="showAddNewRecord1" ClientIDMode="Static" NavigateUrl="#" ImageUrl="~/Images/Add.gif" ToolTip="Add New Products" runat="server" /> <asp:HyperLink ID="showAddNewRecord2" ClientIDMode="Static" Text="Add New Products" NavigateUrl="#" runat="server" /> <br /><br /> <div id="divAddEditRecord" class="ui-widget-content" style="display: none; width: 600px; padding: 0px 10px 20px 10px;"> <h3 id="h3AddEditRecord" class="ui-widget-header">Add New Products</h3> <table> <tr id="trPrimaryKey"> <td>Product ID:</td> <td><asp:HiddenField ID="HfldProductID" runat="server" /></td> <td colspan="2"><asp:TextBox ID="TxtProductID" runat="server" /></td> </tr> <tr> <td>Product Name:</td> <td> <span style="color: red;">*</span> </td> <td><asp:TextBox ID="TxtProductName" MaxLength="0" CssClass="{required:true, messages:{required:'Product Name is required!'}}" runat="server" /></td> <td></td> </tr> <tr> <td>Supplier ID:</td> <td></td> <td><asp:DropDownList ID="DdlSupplierID" DataValueField="SupplierID" DataTextField="CompanyName" AppendDataBoundItems="true" CssClass="{number:true, messages:{number:'Supplier ID is an invalid number!'}}" runat="server"><asp:ListItem Value="">Select One</asp:ListItem></asp:DropDownList></td> <td></td> </tr> <tr> <td>Category ID:</td> <td></td> <td><asp:DropDownList ID="DdlCategoryID" DataValueField="CategoryID" DataTextField="CategoryName" AppendDataBoundItems="true" CssClass="{number:true, messages:{number:'Category ID is an invalid number!'}}" runat="server"><asp:ListItem Value="">Select One</asp:ListItem></asp:DropDownList></td> <td></td> </tr> <tr> <td>Quantity Per Unit:</td> <td></td> <td colspan="2"><asp:TextBox ID="TxtQuantityPerUnit" MaxLength="0" runat="server" /></td> </tr> <tr> <td>Unit Price:</td> <td></td> <td><asp:TextBox ID="TxtUnitPrice" CssClass="{number:true, messages:{number:'Unit Price is an invalid number!'}}" runat="server" /></td> <td></td> </tr> <tr> <td>Units In Stock:</td> <td></td> <td><asp:TextBox ID="TxtUnitsInStock" CssClass="{number:true, messages:{number:'Units In Stock is an invalid number!'}}" runat="server" /></td> <td></td> </tr> <tr> <td>Units On Order:</td> <td></td> <td><asp:TextBox ID="TxtUnitsOnOrder" CssClass="{number:true, messages:{number:'Units On Order is an invalid number!'}}" runat="server" /></td> <td></td> </tr> <tr> <td>Reorder Level:</td> <td></td> <td><asp:TextBox ID="TxtReorderLevel" CssClass="{number:true, messages:{number:'Reorder Level is an invalid number!'}}" runat="server" /></td> <td></td> </tr> <tr> <td>Discontinued:</td> <td> <span style="color: red;">*</span> </td> <td colspan="2"><asp:CheckBox ID="CbxDiscontinued" runat="server" /></td> </tr> <tr> <td colspan="2"></td> <td colspan="2"> <span id="spanAddRecord"><asp:Button ID="BtnAddRecord" Text="Add Record" runat="server" OnClick="BtnAddRecord_Click" /></span> <span id="spanUpdateRecord"><asp:Button ID="BtnUpdateRecord" Text="Update Record" runat="server" OnClick="BtnUpdateRecord_Click" /></span> <input id="inpCancel" type="button" value="Cancel" /> </td> </tr> </table> </div> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server" DataKeyNames="ProductID" ItemType="Northwind45.BusinessObject.Products" SelectMethod="GetGridData" DeleteMethod="DeleteGridItem" onrowdatabound="GridView1_RowDataBound" onrowcreated="GridView1_RowCreated" SkinID="GridViewProfessional"> <Columns> <asp:BoundField DataField="ProductID" HeaderText="Product ID" ReadOnly="true" SortExpression="ProductID" ItemStyle-HorizontalAlign="Right" /> <asp:BoundField DataField="ProductName" HeaderText="Product Name" ReadOnly="true" SortExpression="ProductName" /> <asp:TemplateField HeaderText="Supplier ID" SortExpression="SupplierID" HeaderStyle-Wrap="false"> <ItemStyle Width="30px" HorizontalAlign="Center" /> <ItemTemplate> <div class="tag"> <a href="#" class="gridViewToolTip"><%#: If(Item.SupplierID.HasValue, Item.SupplierID, Nothing) %></a> <div id="tooltip" style="display: none;"> <table style="text-align: left;"> <tr> <td style="white-space: nowrap;"><b>Supplier ID:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.SupplierID, 0) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Company Name:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.CompanyName, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Contact Name:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.ContactName, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Contact Title:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.ContactTitle, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Address:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.Address, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>City:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.City, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Region:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.Region, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Postal Code:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.PostalCode, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Country:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.Country, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Phone:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.Phone, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Fax:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.Fax, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Home Page:</b> </td> <td><%#: If(Item.SupplierID.HasValue, Item.Suppliers.Value.HomePage, Nothing) %></td> </tr> </table> </div> </div> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Category ID" SortExpression="CategoryID" HeaderStyle-Wrap="false"> <ItemStyle Width="30px" HorizontalAlign="Center" /> <ItemTemplate> <div class="tag"> <a href="#" class="gridViewToolTip"><%#: If(Item.CategoryID.HasValue, Item.CategoryID, Nothing) %></a> <div id="tooltip" style="display: none;"> <table style="text-align: left;"> <tr> <td style="white-space: nowrap;"><b>Category ID:</b> </td> <td><%#: If(Item.CategoryID.HasValue, Item.Categories.Value.CategoryID, 0) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Category Name:</b> </td> <td><%#: If(Item.CategoryID.HasValue, Item.Categories.Value.CategoryName, Nothing) %></td> </tr> <tr> <td style="white-space: nowrap;"><b>Description:</b> </td> <td><%#: If(Item.CategoryID.HasValue, Item.Categories.Value.Description, Nothing) %></td> </tr> </table> </div> </div> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="QuantityPerUnit" HeaderText="Quantity Per Unit" ReadOnly="true" SortExpression="QuantityPerUnit" /> <asp:BoundField DataField="UnitPrice" HeaderText="Unit Price" ReadOnly="true" SortExpression="UnitPrice" DataFormatString="{0:c}" HtmlEncode="false" ItemStyle-HorizontalAlign="Right" /> <asp:BoundField DataField="UnitsInStock" HeaderText="Units In Stock" ReadOnly="true" SortExpression="UnitsInStock" DataFormatString="{0:N0}" HtmlEncode="false" ItemStyle-HorizontalAlign="Right" /> <asp:BoundField DataField="UnitsOnOrder" HeaderText="Units On Order" ReadOnly="true" SortExpression="UnitsOnOrder" DataFormatString="{0:N0}" HtmlEncode="false" ItemStyle-HorizontalAlign="Right" /> <asp:BoundField DataField="ReorderLevel" HeaderText="Reorder Level" ReadOnly="true" SortExpression="ReorderLevel" DataFormatString="{0:N0}" HtmlEncode="false" ItemStyle-HorizontalAlign="Right" /> <asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" ReadOnly="true" SortExpression="Discontinued" ItemStyle-HorizontalAlign="Center" /> <asp:TemplateField> <ItemStyle Width="30px" HorizontalAlign="Center" /> <ItemTemplate> <asp:ImageButton ID="IBtnEdit" runat="server" ToolTip="Click to edit" OnClientClick="javascript:return editItem('productID', this.alt);" BorderStyle="None" BackColor="Transparent" ImageUrl="~/Images/Edit.gif" AlternateText='<%#: Item.ProductID %>'/> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemStyle Width="30px" HorizontalAlign="Center" /> <ItemTemplate> <asp:ImageButton ID="IBtnDelete" runat="server" ToolTip="Click to delete" CommandArgument='<%#: Item.ProductID %>' BorderStyle="None" BackColor="Transparent" OnClientClick="javascript:return deleteItem(this.name, this.alt);" ImageUrl="~/Images/Delete.png" AlternateText='<%#: Item.ProductID %>' Width="16" Height="16" CommandName="Delete" /> </ItemTemplate> </asp:TemplateField> </Columns> <EmptyDataTemplate>No records found!</EmptyDataTemplate> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> <asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server" DisplayAfter="0"> <ProgressTemplate> <br /> <img src="Images/ActivityIndicator.gif" alt="" /> Processing your request. Please wait.... </ProgressTemplate> </asp:UpdateProgress> </asp:Content>