webservices : C# Error in visual studio

JoeDoe
Member Posts: 11
Hello,
I have published the page Contact from the classic client. The main goal is simply to show the content of the contact table on a webpage.
Afterwards, I created a web references (called ContactWebRef) in visual studio for my webservices.
I then created a aspx.cs page with that code :
I also created an aspx page with that code :
When I start debugging, I have only two errors but i don't really know how to solve it.
Error 1 : Cannot implicitly convert type 'ContactWebRef.Contact[]' to 'ContactWebRef.Contact_Service[]' C:\Users\John\Documents\Visual Studio 2010\WebSites\WebSite2\Default2.aspx.cs 22 52 C:\...\WebSite2\
Error 2 : 'ASP.default2_aspx' does not contain a definition for 'GridView1_SelectedIndexChanged' and no extension method 'GridView1_SelectedIndexChanged' accepting a first argument of type 'ASP.default2_aspx' could be found (are you missing a using directive or an assembly reference?) C:\Users\John\Documents\Visual Studio 2010\WebSites\WebSite2\Default2.aspx 18
Can you help me ?
I have published the page Contact from the classic client. The main goal is simply to show the content of the contact table on a webpage.
Afterwards, I created a web references (called ContactWebRef) in visual studio for my webservices.
I then created a aspx.cs page with that code :
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using ContactWebRef; public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } private void LoadContacts() { ContactWebRef.Contact_Service InstContact = new ContactWebRef.Contact_Service(); InstContact.UseDefaultCredentials = true; ContactWebRef.Contact_Service[] Contacts = InstContact.ReadMultiple(null, null, 0); GridView1.DataSource = Contacts; } protected void Button1_Click(object sender, EventArgs e) { LoadContacts(); } }
I also created an aspx page with that code :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!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>Ma page de test</title> </head> <body> <form id="form1" runat="server"> <div> <h3>Mon test ici</h3> <p> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> Website </p> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" onselectedindexchanged="GridView1_SelectedIndexChanged"> <Columns> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DB_00ConnectionString %>" SelectCommand="SELECT [Name], [Address] FROM [bii_copy$Contact]"> </asp:SqlDataSource> </div> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> </form> </body> </html>
When I start debugging, I have only two errors but i don't really know how to solve it.
Error 1 : Cannot implicitly convert type 'ContactWebRef.Contact[]' to 'ContactWebRef.Contact_Service[]' C:\Users\John\Documents\Visual Studio 2010\WebSites\WebSite2\Default2.aspx.cs 22 52 C:\...\WebSite2\
Error 2 : 'ASP.default2_aspx' does not contain a definition for 'GridView1_SelectedIndexChanged' and no extension method 'GridView1_SelectedIndexChanged' accepting a first argument of type 'ASP.default2_aspx' could be found (are you missing a using directive or an assembly reference?) C:\Users\John\Documents\Visual Studio 2010\WebSites\WebSite2\Default2.aspx 18
Can you help me ?
0
Comments
-
ContactWebRef.Contact_Service[] Contacts = InstContact.ReadMultiple(null, null, 0);
Correct above code as (if Contact is the name of your WS):
ContactWebRef.Contact Contacts = InstContact.ReadMultiple(null, null, 0);Ufuk Asci
Pargesoft0 -
Thanks. It works fine now !
:thumbsup:0 -
JOE can u please give me the true code, (after correction)
thanks0 -
This is my code, there'snt any error but when I execute the page , only the button is visible and there'snt the gridview even when I click on the button
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Vente_à_Crédit { using webservice; public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } private void LoadCust() { webservice.Customer_Service srv_cust = new Customer_Service(); srv_cust.UseDefaultCredentials = true; srv_cust.Url = "http://localhost:7047/DynamicsNAV/WS/VenteaCredit/Page/Customer"; webservice.Customer[] Customers = srv_cust.ReadMultiple(null, null, 100); GridView1.DataSource = Customers; } protected void Button1_Click(object sender, EventArgs e) { LoadCust(); } } }
0 -
Hi Sbilly,
You left "DataBind" Method.GridView1.DataSource = Customers; GridView1.DataBind();
Best Regards,
YukonMake Simple & Easy0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions