WS on page based Navison and Visual studio (C# and ASP.net)

sbillysbilly Member Posts: 231
edited 2011-10-10 in NAV Three Tier
Hi all;
I am working with WS on page based Navison and Visual studio (C# and ASP.net)
I reproduced the customer card, but I need to put Button previous and next to see different customers like in classic Navision.
who have an idea about how can I do it
thanks

Comments

  • vsnasevsnase Member Posts: 23
    You could buffer customers to a datatable and use http://www.vbforums.com/showthread.php?t=244549 to move to prev or next. Or You could use an array to temp-save customers-no and/or key. But You allways have to remember that s. o. else could have added new customers which are not in your temp-array.

    I am sure there are more solutions to solve this.

    Volker
  • sbillysbilly Member Posts: 231
    thanks volker,
    but i am working with C# and I don't have any idea about VB.
  • MattKeyesMattKeyes Member Posts: 41
    If you use a web service for the customer page (21) and add it to your C# project, then you can use ReadMultiple to read an array of customers. Set a FormView up on a ASP.NET page using the array as the datasource and handle the paging and paging template to use Prev and Next.

    Not the most memory efficient use perhaps (as the entire array will be in memory), but you could tune it pretty easily to suit your needs.

    I did a project as an example but mibuso won't let me attach zip files.

    Default.aspx.cs:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    using CustomerWebService;
    
    public partial class _Default : System.Web.UI.Page 
    {
        private Customer_Service _customerService = null;
        private Customer[] _customerArray = null;
    
        protected void Page_Load(object sender, EventArgs e)
        {
            this.CreateCustomerService();
            this.LoadCustomers();
    
            if (!this.Page.IsPostBack)
            {
                this.BindFormView();
            }
        }
    
        private void CreateCustomerService()
        {
            this._customerService = new Customer_Service();
            this._customerService.UseDefaultCredentials = true;
        }
    
        private void LoadCustomers()
        {
            if (this._customerService != null)
            {
                this._customerArray = this._customerService.ReadMultiple(null, null, 0);
            }
        }
    
        private void BindFormView()
        {
            this._formViewGeneral.DataSource = this._customerArray;
            this._formViewGeneral.DataBind();
        }
    
        protected void _formViewGeneral_PageIndexChanging(object sender, FormViewPageEventArgs e)
        {
            this._formViewGeneral.PageIndex = e.NewPageIndex;
            this.BindFormView();
        }
    }
    
    

    Default.aspx:
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    <%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
    
    <!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></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:FormView ID="_formViewGeneral" runat="server" AllowPaging="True" 
                onpageindexchanging="_formViewGeneral_PageIndexChanging">
                <PagerSettings Mode="NextPreviousFirstLast" />
                <ItemTemplate>
                    <asp:Label ID="_lblCustomerNo" runat="server" Text="No."></asp:Label>
                    <asp:TextBox ID="_txtCustomerNo" runat="server" Text='<%# Bind("No") %>'></asp:TextBox>
                    <br />
                    <asp:Label ID="_lblCustomerName" runat="server" Text="No."></asp:Label>
                    <asp:TextBox ID="_txtCustomerName" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                </ItemTemplate>
                <PagerTemplate>
                <asp:Button ID="_btnFirst" runat="server" Text="First" CommandName="Page" CommandArgument="First"/>
                <asp:Button ID="_btnBack" runat="server" Text="Previous" CommandName="Page" CommandArgument="Prev"/>
                <asp:Button ID="_btnNext" runat="server" Text="Next" CommandName="Page" CommandArgument="Next"/>
                <asp:Button ID="_btnLast" runat="server" Text="Last" CommandName="Page" CommandArgument="Last"/>
                </PagerTemplate>
            </asp:FormView>
        </form>
    </body>
    </html>
    
    

    As I said, this is rough, but it should illustrate the idea.
  • sbillysbilly Member Posts: 231
    thanks very much
    please can u send me the project by e-mail.
    This my adress : sandi_bilel@yahoo.fr
    thanks again
  • MattKeyesMattKeyes Member Posts: 41
    Hi, sent it to you in a PM
  • sbillysbilly Member Posts: 231
    Soory But I didn't recieve anything, nothing is attached;
    Please send it on my yahoo mail
    thanks
  • MattKeyesMattKeyes Member Posts: 41
    Apologies... forgot to hit the "add the file" button in the PM. You should have it now.
  • sbillysbilly Member Posts: 231
    MattKeyes wrote:
    Apologies... forgot to hit the "add the file" button in the PM. You should have it now.
    Thanks very much, it will help me so much.
    Please can you see this topic and give me your advice:
    viewtopic.php?f=32&t=47282
  • MattKeyesMattKeyes Member Posts: 41
    I answered a similar one. See here:

    viewtopic.php?f=32&t=47339
  • sbillysbilly Member Posts: 231
    Shall I use "gridview" or "listview" and how can I use them
  • MattKeyesMattKeyes Member Posts: 41
    It depends on your requirements. As for how to use them... that is a bit like saying "how do I program?" It is a broad question and not really directly answerable, sorry. Practice and study is what I would suggest unless you have specific questions.
  • philipuskdphilipuskd Member Posts: 36
    Hi all. just to let you know that this topic helps me a lot on how displaying the NAV data in ASP.NET using webservice.

    how can I make the FormView is enabled for editing, insert new records and or deleting records from th NAV database? I saw a video tutorial on how to make this posible using SQLDataSource by selecting Generate INSERT, UPDATE, and DELETE statements, but it seem cannot be applied using a data colection received from readMultiple method.

    any idea how to mimic the behavior of update hyperlink colomn when we enable editing of a gridview?

    Thx
Sign In or Register to comment.