Introduction
Cascading info path list controls as drop down list and list box controls programmatically
at which the value displayed of the second control depends according to the selected
value in the first control.
Steps
A) Creating the Database:
- Open SQL Server Enterprise Manager through : (Start > All Programs >
Microsoft SQL Server > Enterprise Manager), then in Console Root folder expand the Microsoft
SQL Servers then expand the SQL Server Group then expand your instance then at the
Databases folder right click on it and create a new database called “CascadDB” then
expand the CascadDB database and right click on Tables to create a new table called
“Domain” this table holds two columns: (DomainID – DomainName) and another table
called “Vendor” this table holds three columns : (VendorID – DomainID - VendorName)
as shown in this figure:
B) Creating the Web Service:
- Open MS- visual studio .net 2005 then click File menu > New > Web Site >
ASP.Net Web Service : Then in the App_Code folder open Service.cs file then add
these namespaces: Using System. Data; Using System.Data.SqlClient; Then, add this
web method to get all of the domain names from Domain table in the CascadDB database:
|
[WebMethod]
public
DataSet GetDomainNames()
{
SqlConnection con = new
SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial
Catalog=CascadDB");
SqlDataAdapter da = new
SqlDataAdapter("SELECT Domain.DomainName FROM Domain",
con);
DataSet ds = new DataSet();
con.Open();
da.Fill(ds,
"Domain");
con.Close();
con =
null;
da =
null;
return ds
}
Then
, add this web method to get all vendor names according to the selected domain names
:
[WebMethod]
public
DataSet GetVendorsForSelectedDomains(string
strInputDomainName)
{
SqlConnection con = new
SqlConnection("Data Source=(local);Integrated Security=SSPI;Initial
Catalog=CascadDB");
SqlCommand com = con.CreateCommand();
com.Parameters.AddWithValue("@InputDomainName", strInputDomainName);
com.CommandText = "SELECT Vendor.VendorName FROM Vendor INNER JOIN [Domain]
ON Vendor.DomainID = [Domain].DomainID Where [Domain].DomainName = @InputDomainName";
strInputDomainName
= strInputDomainName.Replace("'",
"''");
SqlDataAdapter daa = new
SqlDataAdapter();
daa.SelectCommand =
com;
DataSet Ds = new DataSet();
con.Open();
daa.Fill(Ds,
"Vendor");
con.Close();
con =
null;
daa =
null;
return Ds;
}
|
Which shown in this figure:
Then, run this service as shown in this figure :
Then click on the GetDomainNames link , then invoke the webmethod as shown in the
figure:
Then after invoking the webmethod , it should return All of the domain names as shown in the figure:
Then click on the GetVendorsForSelectedDomains link , then invoke the webmethod
as shown in the figure:
Then after invoking the webmethod , it should return All of the vendor names according
to the selectd domain names as shown in the figure:
C) Creating the Compatible InfoPath form & Publishing:
- Open Microsoft Office InfoPath 2007 then design a new blank form template which
explained before in the previous articles ,then add a table with title layout and
add two drop down list controls to it in which the first control populated with
the domain names and the other one’s populated with values according to the selection
of the first control from the CascadDB database via the created web service , as
shown in the figure:
Then from Tools menu > Data Connections, as shown in the figure:
Then select receive data in order to receive data via the web service as shown in
the figure:
Then select the resource of your data as a web service as shown in the figure:
Then write the URL of the location of the web service you want to use as your data
connection as shown in the figure:
Then you’ll find the web methods which wrote in the web service which called “GetDomainNames”
& “GetVendorsForSelectedDomains” as shown in the figure:
Then store a copy of the data in the form template as
shown in the figure:
Then check on the automatically retrieve data when form is opened as shown in the
figure:
Then you’ll get the data connection source
for the form template as shown in the figure:
Then repeat these steps again but this time for “GetVendorsForSelectedDomains” web
method as shown in this figures:
Then Click on Next, as shown in the figure:
Then check on save a copy of the data in the form template, as shown in the figure:
Then, Click on Finish, as shown in the figure:
Then, Click on close button, as shown in the figure:
Then right click on the domain drop down list and click on drop down list box properties
as shown in the figure:
Then at the list box entries select look-up values from an external data source
as shown in the figure:
Then click on the entries button as shown in the figure:
Then expand the data fields till reach to the DomainName data filed as shown in
the figure:
Then you’ll find the X-path to the DomainName data field in the entries textbox
as shown
in the figure:
Then check on the validations and rules and press on the Rules button, as
shown in the figure:
Then press Add button as shown in the figure:
Then press on Add Action button as shown in the figure:
Then add these rules and press ok button as shown in the figure:
Then right click on the vendor drop down list and click on drop down list box properties
as shown in the figure:
Then at the list box entries select look-up values from an external data source
as shown in the
figure:
Then click on the entries button as shown in the figure:
Then expand the data fields till reach to the VendorName data filed as shown in the figure:
Then you’ll find the X-path to the VendorName data field in the entries textbox
as shown in the figure:
Then check on the validations and rules and press on the Rules button, as shown in the figure:
Then press Add button as shown in the figure:
Then add this rule & condition and press ok button as shown in these figures:
Then, Add Action and click on OK button, as shown in
the figure:
Then from the preview tab click on form item to run the form as shown in the figure:
Here’s the result after running the form: (selecting Domain1 and getting the corresponding
vendors), as shown in the figure:
Then close the preview as shown
in the figure:
Then from Tools menu > Form
options >: At the security and trust category
> security level > set full trust (the form has access to files and settings
on the computer, then at the form template signature > check on the sign this
form template, as shown in the figure :
Then, click on File menu > Publish, as shown in the figure:
Then select to a network location, as shown in the figure:
Then write the path and the file name for the published form template,
as shown in the figure:
Then remove the path from this textbox, as shown in the figure:

Then click on Publish button, as shown in the figure:
Then click on close button, as shown in the figure:
Then open the central administration which explained before in the previous articles
and click on the Application Management tab > InfoPath forms services > Manage
form templates, as shown in the figure:
Then click on upload form templates, as shown in the figure:
Then click on the browse button to upload the published form template, as shown
in the figure:
Then click on upload button as shown in the figure:
Then click on Ok button, as shown in the figure:
Then right click on the new published form template > Activate to a site collection,
as shown in the figure:
Then at the activation location section, right click on the site collection drop-down
list and select change site collection, as shown in the figure:
Then right click on the web application drop-down list and select change web application,
as shown in the figure:
Then click on the sharepoint-80 link, as shown in the figure:
Then from the URL section select your site link, as shown in the figure:
Then click ok button, as shown in the figure:
D) Creating the Sharepoint Site Document-Library:
- Use the same steps that were explained before in the previous article in order to
create a sharepoint site and a document library so , here I created another document
library called “CascadDocLib” in order to publish the published form template to
it as a content type , as shown in the figure :
Then click on Settings tab > Document library settings, as shown in the figure:
Then, at the content types section click on add from existing site content type’s
link, as shown in the figure:
Then from the available site content types, select the published content type “Newtemp3”
and add it, as shown in the figure:
Then go back to the CascadDocLib page and click on New tab , then click on the Newtemp3
item , as shown in the figure:
Then, the result will be like this:
Then you can save the document as shown in the figure:
Then you can go back to the CascadDocLib page and see the saved document as shown
in the figure:
|