developer.com
Search EarthWeb
CodeGuru | Gamelan | Jars | Wireless | Discussions
Navigate developer.com
Architecture & Design  
Database  
Java
Languages & Tools
Microsoft & .NET
Open Source  
Project Management  
Security  
Techniques  
Voice  
Web Services  
Wireless/Mobile
XML  
Technology Jobs  

   Developer.com Webcasts:
  The Impact of Coding Standards and Code Reviews

  Project Management for the Developer

  Defining Your Own Software Development Methodology

  more Webcasts...




See the Winners!


Linked Data Planet Conference & Expo


Developer Jobs

Be a Commerce Partner
Cell Phones
Promote Your Website
Phone Cards
Imprinted Promotions
Home Improvement
Computer Deals
Baby Photo Contest
Disney World Tickets
Compare Prices
Remote Online Backup
Calling Cards
Compare Prices
Domain registration
Web Hosting Directory

 


 Silverlight 2 SDK for Visual Studio 2008
This package is an add-on to the RTM release of Visual Studio 2008 to provide tooling for Microsoft Silverlight 2 Beta 1. It provides a Silverlight project system for developing Silverlight applications using C# or Visual Basic. »
 
 Article: What Does it Take to Build the Best RIA?
With the proliferation of Rich Interactive Application (RIA) platform choices out there, you no longer have to take a one-size-fits-all approach to developing your next RIA application. Knowing the strengths (and weaknesses) of each platform can help you to decide the best RIA for your next application. »
 
 Expression Blend 2.5 Preview
Use Expression Blend 2.5 to create and modify managed Silverlight 2-based applications. Expression Blend for Silverlight 2 includes all of the features in Expression Blend 2 but has not reached the quality level of Expression Blend 2 for WPF or Silverlight 1 development. »
 
 The Hottest Mobile Platform Meets the Hottest RIA Platform
With the Symbian OS now supporting Microsoft Silverlight, mobile developers can bring new and exciting capabilities to handsets all over the globe. Find out why developers now need to make mobile devices a core part of their RIA development strategy. »
 
 Article: Leveraging Your Flash Development with Silverlight
You're not giving up Flash any time soon (and we don't blame you.) But if you could get your Flash application working in Silverlight, why wouldn't you? We show you the tools and techniques required to have your rockin' Flash application rolled for Silverlight. »
 
Related Article -
InfoPath 2003
Developer News -
SaaS Tool Offers Custom Database Development    May 9, 2008
Microsoft’s Automated Agent: Can We Talk?    May 7, 2008
Borland Finally Sells CodeGear    May 7, 2008
Red Hat Heads For The JON 2.0    May 7, 2008
Free Tech Newsletter -

Project Management Guide: Developing a Web Site. Best Practices, Tips and Strategies. Download Exclusive eBook Now.

Dynamically Data-bind in InfoPath
By Thiru Thangarathinam

Go to page: 1  2  Next  

In Part 1 of this article series, we looked at some of the powerful and compelling features of InfoPath 2003. In this installment, we will see how to create a dynamic data-bound InfoPath from an ASP.NET Web Service. We will also see how to customize the task pane by adding custom content that is relevant to the form that the user is filling out.

Creating a Data-Bound InfoPath Using an ASP.NET Web Service as the Data Source

In this section, we will understand how to construct a dynamic, data-bound InfoPath form using an ASP.NET Web Service as the data source. Before we move on to consuming a Web Service from an InfoPath form, let us create an ASP.NET Web Service, which can then be used from within an InfoPath form.

Creating an ASP.NET Web Service

Let us start by creating a Web Service named InfoPathWebServiceExample by selecting Visual C# ASP.NET Web Service as the project template in the New Project dialog box. Once the project is created, rename the default service from Service1 to AuthorsService. To the AuthorsService, add the following two methods:

[WebMethod]
public XmlDocument GetAuthorByAuthorID(string authorID)
{
  XmlDocument doc = new XmlDocument();
  DataSet authorsDataSet = new DataSet("Authors");
  using (SqlConnection conn = new
SqlConnection("server=localhost;uid=sa;pwd=thiru;database=Pubs"))
  {
    SqlDataAdapter adapter = new SqlDataAdapter("Select au_id,
                             au_lname, au_fname,
                             phone from authors
                             Where au_id = '" +
                             authorID + "'" ,conn);
    adapter.Fill(authorsDataSet,"Author");
  }
  doc.LoadXml(authorsDataSet.GetXml());
  return doc;
}

[WebMethod]
public XmlDocument GetAllAuthors()
{
  XmlDocument doc = new XmlDocument();
  DataSet authorsDataSet = new DataSet("Authors");
  using (SqlConnection conn = new
         SqlConnection("server=localhost;uid=sa;pwd=thiru;
                        database=Pubs"))
  {
    SqlDataAdapter adapter = new SqlDataAdapter("Select au_id,
                             au_lname, au_fname,
                             phone from authors " ,conn);
adapter.Fill(authorsDataSet,"Author");
  }
  doc.LoadXml(authorsDataSet.GetXml());
  return doc;
}

The above methods are very similar except for the difference that the GetAuthorByAuthorID method takes an authorID as an argument and returns information about that particular author. The GetAllAuthors method returns all the authors present in the authors table in the pubs database. If you navigate to the AuthorsService.asmx file from the browser and invoke the GetAllAuthors method using the default test harness provided by ASP.NET, you will get the following output.



Click here for a larger image.

Creating the InfoPath form

Now that we have constructed the Web Service, let us create the InfoPath form. To create the form, go through the following steps.

  1. Start by selecting File->Design a Form from the menu.
  2. In the Design a new form task pane, click on New from Data Source.
  3. Select Web Service as the type of the data source in the first screen of the Data Source Setup Wizard. Clicking on Next in the first screen results in the following screen.
  4. In the above screen, you must indicate how the form will interact with the Web Service, indicating options such as whether it receives and submits data to the service. You can build a form that only sends data, one that only receives data, or one that does both. If you choose Receive and submit data in the above screen, InfoPath will create two views for your form: one view for submitting data to the service and another view for the data returned from the service. In this case, the data source view also contains two groups of fields. The queryFields contain the data that needs to be supplied when invoking the service. The dataFields contain the data returned from the Web Service. For the purposes of this article, let us select Receive data option in the above screen. Clicking Next on the above screen results in the following screen, where you need to specify the location of your Web Service.
  5. In the above screen, enter the location of the Web Service and click Next.
  6. From the location of the Web Service specified, InfoPath extracts the WSDL definition and displays the available Web Service methods.
  7. In the above screen, select the GetAllAuthors method from the list and click Next to complete the wizard.
  8. After that, open up the Data Entry View from the task pane and then click on Data Source.
  9. In the Data Source treeview, open up the dataFields node and select the Authors node. Right-click on the Authors node and select the Section with Controls option from the context menu.
  10. Now, navigate back to the Query view and then click on the Preview Form option from the toolbar.
  11. In the Preview mode, if you click on the Run Query button, you will see the following output being displayed.


  12. Click here for a larger image.

    The above output is retrieved from the GetAllAuthors Web Service method call that returns details about all the authors.

Go to page: 1  2  Next  


Tools:
Add www.developer.com to your favorites
Add www.developer.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed


Microsoft & .NET Archives

Generate Complete .NET Web Apps in Minutes . Download Iron Speed Designer today.
Five Trends for Application Development & Program Management. Download Complimentary Report Now.
Best Practices for Developing a Web Site. Checklists, Tips & Strategies. Download Exclusive eBook Now.
Learn about expanding business opportunities for the reseller channel. Visit IT Channel Planet.
Data Sheet: IBM Information Server Blade



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES