<%@ Page Title="Products" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="GridViewMoreInfo_Products.aspx.cs" Inherits="Northwind45.GridViewMoreInfo_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/gridview-moreinfo-script.js"%>
    <script type="text/javascript">
        var urlAndMethod = "GridViewMoreInfo_Products.aspx/GetProducts";
 
        $(function () {
            InitializeToolTip();
 
            $("#inpClose").click(function () {
                var options = {};
                $("#divMoreInfo").hide('blind', options, 300);
                return false;
            });
        });
 
        function assignRetrievedItems(msg) {
            $("#<%=TxtProductID.ClientID %>").val(ConvertNullToString(msg.d.ProductID));
            $("#<%=TxtProductName.ClientID %>").val(ConvertNullToString(msg.d.ProductName));
            $("#<%=TxtSupplierID.ClientID %>").val(ConvertNullToString(msg.d.SupplierID));
            $("#<%=TxtCategoryID.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="divMoreInfo" class="ui-widget-content" style="displaynonewidth600pxpadding0px 10px 20px 10px;">
        <h3 id="h3MoreInfo" class="ui-widget-header">Products Details</h3>
        <table>
            <tr>
                <td>Product ID:</td>
                <td></td>
                <td><asp:TextBox ID="TxtProductID" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td>Product Name:</td>
                <td></td>
                <td><asp:TextBox ID="TxtProductName" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td>Supplier ID:</td>
                <td></td>
                <td><asp:TextBox ID="TxtSupplierID" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td>Category ID:</td>
                <td></td>
                <td><asp:TextBox ID="TxtCategoryID" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td>Quantity Per Unit:</td>
                <td></td>
                <td><asp:TextBox ID="TxtQuantityPerUnit" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td>Unit Price:</td>
                <td></td>
                <td><asp:TextBox ID="TxtUnitPrice" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td>Units In Stock:</td>
                <td></td>
                <td><asp:TextBox ID="TxtUnitsInStock" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td>Units On Order:</td>
                <td></td>
                <td><asp:TextBox ID="TxtUnitsOnOrder" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td>Reorder Level:</td>
                <td></td>
                <td><asp:TextBox ID="TxtReorderLevel" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td>Discontinued:</td>
                <td></td>
                <td><asp:CheckBox ID="CbxDiscontinued" ReadOnly="true" runat="server" /></td>
            </tr>
            <tr>
                <td colspan="2"></td>
                <td><input id="inpClose" type="button" value="Close" /></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"
            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"><%#: Item.SupplierID.HasValue ? Item.SupplierID : null %></a>
                                <div id="tooltip" style="displaynone;">
                                    <table style="text-alignleft;">
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Supplier ID:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.SupplierID : 0 %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Company Name:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.CompanyName : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Contact Name:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.ContactName : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Contact Title:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.ContactTitle : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Address:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.Address : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>City:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.City : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Region:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.Region : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Postal Code:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.PostalCode : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Country:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.Country : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Phone:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.Phone : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Fax:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.Fax : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Home Page:</b>&nbsp;</td>
                                            <td><%#: Item.SupplierID.HasValue ? Item.Suppliers.Value.HomePage : null %></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"><%#: Item.CategoryID.HasValue ? Item.CategoryID : null %></a>
                                <div id="tooltip" style="displaynone;">
                                    <table style="text-alignleft;">
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Category ID:</b>&nbsp;</td>
                                            <td><%#: Item.CategoryID.HasValue ? Item.Categories.Value.CategoryID : 0 %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Category Name:</b>&nbsp;</td>
                                            <td><%#: Item.CategoryID.HasValue ? Item.Categories.Value.CategoryName : null %></td>
                                        </tr>
                                        <tr>
                                            <td style="white-spacenowrap;"><b>Description:</b>&nbsp;</td>
                                            <td><%#: Item.CategoryID.HasValue ? Item.Categories.Value.Description : null %></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="IBtnMoreInfo" runat="server" ToolTip="Click for more info"
   	                       OnClientClick="javascript:return viewItem('productID', this.alt);"
   	                       ImageUrl="~/Images/MoreInfo.gif" AlternateText='<%# Item.ProductID %>'/>
                        </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>