Categories

Tools

bitdefender

1&1 Web Hosting

Example of how to use Ajax control Accordation associated with an Access database


This complete sample, shows how to use the Ajax control Accordation associated with a database Access to view invoice information.

Code:

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

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Example of how to use Ajax control Accordation associated with an Access database - MdmSoft</title>
    <style type="text/css">
        body {
            font-family: Verdana;
            font-size: 12px;
        }

        .header {
            border: 1px solid #777;
            color: #333;
            margin: 4px;
            padding: 2px;
        }

            .header :hover {
                color: #0094ff;
            }

        .content {
            background-color: lightyellow;
            border: 1px solid #777;
            border-radius: 4px;
            margin-left: 20px;
            padding: 5px;
        }

            .content h2.title {
                border-bottom: 1px solid #777;
                color: #333;
                font-size: 12px;
                margin: 0;
                padding: 0;
            }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:ToolkitScriptManager ID="tsmInvoices" runat="server"></asp:ToolkitScriptManager>
            <asp:Accordion ID="AccordionInvoices" runat="server"
                ContentCssClass="content"
                DataSourceID="AccessDataSourceInvoices"
                FadeTransitions="true"
                HeaderCssClass="header"
                Width="470px">

                <HeaderTemplate>
                    <b>Invoice N°: 
                        <%#DataBinder.Eval(Container.DataItem, "OrderID")%>
                         of 
                        <%# String.Format("{0:D}",Eval("OrderDate")) %>
                    </b>
                </HeaderTemplate>
                <ContentTemplate>
                    <h2 class="title">Invoice detail: N° <%#DataBinder.Eval(Container.DataItem, "OrderID")%></h2>
                    <div class="">
                        <%#DataBinder.Eval(Container.DataItem, "CompanyName")%>
                        <br />
                        <%#DataBinder.Eval(Container.DataItem, "Address")%>
                        <br />
                        <%#DataBinder.Eval(Container.DataItem, "City")%>
                        <br />
                        <%#DataBinder.Eval(Container.DataItem, "PostalCode")%> - 
                        <%#DataBinder.Eval(Container.DataItem, "Country")%>
                        <br />
                        Total: <%# String.Format("{0:C}",Eval("ExtendedPrice")) %>
                    </div>
                </ContentTemplate>

            </asp:Accordion>

            <asp:AccessDataSource ID="AccessDataSourceInvoices" runat="server"></asp:AccessDataSource>
        </div>
    </form>
</body>
</html>

 

Code:

using System;

public partial class AccordationDemo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessDataSourceInvoices.DataFile = Server.MapPath("~/App_Data/Northwind.mdb");

        AccessDataSourceInvoices.SelectCommand = @"SELECT TOP 10 
                                                    OrderID,
                                                    OrderDate,
                                                    Customers.CompanyName,
                                                    Address,
                                                    City,
                                                    PostalCode,
                                                    Country,
                                                    ExtendedPrice
                                                    FROM Invoices";
        AccordionInvoices.DataBind();
    }
}

 

Result:

Example of how to use Ajax control Accordation associated with an Access database

Example of how to use Ajax control Accordation associated with an Access database

Posted in Ajax by MdmSoft

If our work has been of help, you can help us with a small donation...
Our programmers will thank you!



All information contained in this web site are the property of MdmSoft. The information is provided "as is", MdmSoft will not be liable for any misuse of the code contained in these pages, nor can it be for inaccuracies, grammatical errors or other factors that may have caused damage or lost earnings. MdmSoft is not responsible for the content of comments posted by users.
The examples in this area have the educational and demonstration purposes only, and may be copied only for your reference, but cannot be used for commercial purposes, or for any other purpose, without the express written consent of MdmSoft.
MdmSoft also reserves the right to change, without notice, to your liking this web site, the pages and its sections, and may suspend temporarily or definitely the various services included on this site.
While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy.