Populating and Implementing 4 Dropdown lists on web form through web service

Hi all,

I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my SQL statements in the Data Acess Layer to create more secure web service application. The Web service class is also in the Data Access Layer. I need to populates the 4 Dropdown list boxes on the web form from one table. I have Customer table which contains information About CustomerName, CustomerType, Address, City. These 4 colum values should populate the 4 Dropdown lists. And then I need to implement those 4 dropdowns like this. When the user selects a Customername it should display relevant customer information in the GridView. Or when the user selects values from all 4 listboxes it should display all information on GridView as well.

For all the above I have just populated one listbox but I don't know how to populate the other 3 dropdown lists and implement them on the web form.

I have created one method in the Data Access Layer class and one method in the Web Service class and then I instaitiated the web service object in the web form by adding a web reference. It works fine for just populating one dropdown list box but for the whole 4 dropdown list I am unable to populated and Implement them.

Below are the methods and the code for one dropdownlist.

 

(1)Web Form code:


 WebService.Service ws = new WebService.Service();

 protected void Page_Load(object sender, EventArgs e)
      {


         object[] alist;
         alist = ws.GetBusinessType(string.Empty);
         DropDownList1.DataSource = alist;
          DropDownList1.DataBind();
     


(2) Web Service Method:


      [WebMethod]
      public ArrayList GetBusinessType(string btype)
      {
                  DAccess ODA = new DAccess(); //Data Access object
                  ArrayList list = new ArrayList();

                  list = ODA.GetBusinessType(btype); //Data Access method

                  return list;

      }


(3) Data Access method:

public ArrayList GetBusinessType(string btype)
      {
         SqlConnection connection = GetConnection;
         try
         {
            ArrayList arrbt = new ArrayList();

                      
            StringBuilder sql = new StringBuilder()
            .AppendLine("SELECT")
            .AppendLine("\tTYPENAME")
            .AppendLine("\tFROM")
            .AppendLine("\tBUSINESS_TYPE");

            SqlParameter paramTYPENAME = new SqlParameter("TYPENAME", SqlDbType.NVarChar);
            paramTYPENAME.Value = btype;

            connection.Open();

            SqlDataReader reader = ExecuteQuery(connection, sql.ToString(), paramTYPENAME);
           
            while (reader.Read())
            {             
              string result = reader["TYPENAME"].ToString();
              arrbt.Add(result);            

            }

            return arrbt;
         }
         catch (Exception ex)
         {
            return null;
            //do some log here Call a class that logs the errors
         }
         finally
         {
            connection.Close();
         }


All the above code works fine for just populating the one dropdown list but not implementing. I just want the implementation something like....When the user select one dropdown or all of them then it should display the result in the gridview. I have not shown the aspx code here but the main thing is the code above. Can any one help me to implement this

I really appreciate your help. Looking forward to your reply.

Thanks

Koonda

0
koonda
4/15/2007 1:57:35 PM
asp.net.xml-web-services 7071 articles. 0 followers. Follow

8 Replies
1236 Views

Similar Articles

[PageSpeed] 24

In your Page_Load, you have no test for not IsRepost! The dropdownlist was keep getting re-loaded. Why not load all the drop-down lists during page_load or are you trying to get a cascade whereby selecting one dropdown selects the records to populate the next?

You will need to disable postback for each of the DDL and provide a command button to load the GridView.


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
TATWORTH
4/15/2007 5:56:11 PM

Thanks TATWORTH for your quick reply. I also have page postback thing but I forgot to include in the code. The main problem is how can I populate the 4 Dropdowns from just one table and then how to implement them?

 

Please give me more ideas, suggestions, and code examples to figure out the problem. You can see my code above but I cannot implement it further for 3 more dropdownlists and other functionality for users when they select they should get the desired output.

 

Thanks and looking forward to your reply.

 

Koonda

0
koonda
4/15/2007 8:28:07 PM
Without knowing your table structure, I cannot think of what could be put in the other DDL.

Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
TATWORTH
4/15/2007 10:03:46 PM

Sorry for my late reply I was very busy. Ok, I have a table called Customer. I have the columns BusinessName, BusinessType, Address, City. I want to populate 4 Dropdownlist boxes for each of these 4 column from the Customer table. Then I want to implement it. Your urgent required if possible for you because I have very short time to submit the project.

Looking forward to your reply.

 

Thanks

 

Koonda 

 

 

0
koonda
4/18/2007 7:26:34 PM

From you reply, I a, assuming that that BusinessName, BusinessType, Address, City are all stored as text within the Customer table. Hence you need the following TSQL to populate your other drop-down lists.

SELECT '   ' UNION SELECT DISTINCT BusinessName FROM Customer ORDER BY 1

SELECT '   ' UNION SELECT DISTINCT BusinessType FROM Customer ORDER BY 1

SELECT '   ' UNION SELECT DISTINCT Address FROM Customer ORDER BY 1

SELECT '   ' UNION SELECT DISTINCT City FROM Customer ORDER BY 1

In your select pass in all 4 as VARCHAR(50?), then

IF DATALENGTH(RTRIM(@BusinessName )) = 0 SET @BusinessName = Null   -- and so on

SELECT BusinessName, BusinessType, Address, City FROM CUSTOMER

WHERE COALESCE(@BusinessName, BusinessName) = BusinessName

AND COALESCE(@City , City ) = City -- and so on for other columns

This will have the effect of allowing a selection from any combination.

 

 


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
TATWORTH
4/19/2007 6:38:01 AM

Thanks for your reply but I am still confused on this querry. Did you mean that I should use this Query in the Data Access Layer?. But the other issue is on the implementation. Would you be able to send me some code examples relating to my question? I really appreciate your help.

 

Looking forward to your reply.

 

Koonda

0
koonda
4/19/2007 10:41:16 AM

These are for you drop-down lists

SELECT '   ' UNION SELECT DISTINCT BusinessName FROM Customer ORDER BY 1

SELECT '   ' UNION SELECT DISTINCT BusinessType FROM Customer ORDER BY 1

SELECT '   ' UNION SELECT DISTINCT Address FROM Customer ORDER BY 1

SELECT '   ' UNION SELECT DISTINCT City FROM Customer ORDER BY 1


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
TATWORTH
4/19/2007 11:02:59 AM

In you select stored procedure to populate the datagrid (or gridview), use something like:

Pass in the select parameters as VARCHAR(50?), then

IF DATALENGTH(RTRIM(@BusinessName )) = 0 SET @BusinessName = Null   -- and so on

SELECT BusinessName, BusinessType, Address, City FROM CUSTOMER

WHERE COALESCE(@BusinessName, BusinessName) = BusinessName

AND COALESCE(@City , City ) = City -- and so on for other columns

This will have the effect of allowing a selection from any combination.

Regrettably, I will not be able to provide you with sample code until the weekend when I will be at home and on my own development box. Please post a message around 12:00 UTC next Friday to remind me.

 


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
TATWORTH
4/19/2007 11:13:05 AM
Reply:

Similar Artilces:

xml web service --uploading the file to the xml web service
how can we upload the file in the xml web service 1.i mean what will be the return value in the proxy class 2.and how am i going to send the file to the xml web service----regards Bipul Kumar Here are some links to articles that helped us get this done: http://msdn.microsoft.com/webservices http://www.microsoft.com/downloads/details.aspx?familyid=06255a94-2635-4d29-a90c-28b282993a41&displaylang=en https://www.sys-con.com/dotnet/article.cfm?id=458 Hope this helps....

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="http://www.dynix.com/schema/book">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

XML Web service , Web form
hi i hope if u could help me in what i am making so i have a web form that does the collection of the information from the user when he hits the button this data must be sent to the xml web service but this service must deliver this data in xml then i read the information and insert it to the sql serevr Database could you help me becouse iam soo confused about where to start and what is the stuff to search in it iam new in the xml stuff help me pleaseeeeee“To be incredible you must produce great work”Visit My Bloghttp://www.dotnetjunkies.com/WebLog/hussein My first question is why are yo...

.NET web services Vs Java Web Services
Hello, does anyone know of a book or good source of information that compares .NET and Java Web Services? (I would like soemthing neutral if possible). I am thinking of approaching this subject for my dissertation? Many Thanks Rob Hi Rob, Last year I had to give a powepoint presentation on Web Services. I noticed some good books at barnes and noble that discussed the subject. These books were specific to Java and discussed Web Services in a very clear fashion. They gave some elementary examples that were easy to understand. I have not yet had the pleasure of creatin .NET Web Servi...

Web Site Project: How to configure web service URL in web.config (web service defined in a referenced DLL)
I have a web site that references a business logic DLL project. In the business logic project, there is a web service defined in its app.config file something like this: <applicationSettings>  <MyNamespace.BLL.Properties.Settings>    <setting name="MyNamespace_BLL_MyServer_ServiceName" serializeAs="String">    <value>http://blah.blah.blah.asmx</value>  </setting>  </MyNamespace.BLL.Properties.Settings></applicationSettings> When the web site is published, the web ...

Web Service Client for Sharepoint Web Service Lists.asmx
Can retrieve lists on home page but not deeped. For example, http://myportal/default.aspx works with Web Reference http://myportal/_vti_bin/Lists.asmxHowever, I need a list from this page http://myportal/C6/Facility%20Rentals/default.aspxand the only Web Reference that i can get close is http://myportal/C6/_vti_bin/Lists.aspxand this one can not see the List I need. I have the correct List and View GUID hexnumbers. Please help!!!!! I have also tried the List Data Retrieval Service   DspSts.asmx and am not able to return any listsexcept for top level lists. Please help. Dim stsQu...

web web web
Name: bahadir Email: sensiz_olmuyor_t1_at_hotmail.com Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfası yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

Manipulating Microsoft DNS service from web service or web form.
Hiya All,   I need to be able to update an "A record" on Microsoft DNS Service for a particular domain from a web form or web service - and have no idea where to begin. I can run the form/service on the same box running DNS service... I am looking to make a IP address updater that will update my "home" ip address if it changes (similar to what DYNDNS offers, except I have my own name servers, so that wont work for me lol). Any kick in the right direction is greatly appreciated!   Dave...

Is web services a part of web Service?
  I have a question: Is web services a part of web server?? And when the client calls web service, it means that client calls web server?? Or is it a different entity in itself which communicates separately both with client and server and acts as middleware application.. I am very confused.. Can someone explain me the architecture...??? Thanks..Dont forget to click "Mark as Answer" on the post that helped you.This credits the member,earns you a point & marks your thread as Resolved so that new users will know where to search for their queries. When you build and dep...

Calling a Web Service from a Web Service
Hello,I was looking for some feedback on calling a web service from within a web service. I've heard that it's not good practice (or not possible). I have a scenario where I think it might make some sense.Within our infrastructure, we've created a web service that handles incoming updates on the statuses of all processes. This has proven to be a good thing since it allows applications to communicate across server to make status updates. It's also used by third party developers and applications to communicate with our infrastructure.Along these lines ... we are planning to create a new compon...

what are web services and what are the advantages of web services?
 Hello  i am new to this .net stuff and i was ask on the job interview what a web services is?and if i did not know given that i had a project ( as a project manager,  or a web developer)   what  is it? how do i start a >NET project on it? what are the main advantages is?  HOW DO I START THIS IN THE INTERVIEW>  and what basic books do i buy?   Hi There, There plenty of source on the net about webservice Definiton: http://en.wikipedia.org/wiki/Web_service http://www.codeproject.com/Purgatory/Defining_Web_Services.asp...

What action by a web service requires an app to update their web reference to a Web Service
I create a web reference to a web service in my aspx web application which returns an XML object. If the owner of the web service makes a change to their object am I required to do an update web reference? What if I dont use the information from the new object? thanks Larry You should make the change only if the contract b/w the two has changed (e.g. parameters, return values), etc.-Mathew Nolton Website=www.cybral.com Email=mnolton@cybral.com Blog=weblogs.asp.net/mnolton If the web service now returns a new element and my class reference doesn't match their new class ref...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

Web resources about - Populating and Implementing 4 Dropdown lists on web form through web service - asp.net.xml-web-services

Implementing Recommendations of the 9/11 Commission Act of 2007 - Wikipedia, the free encyclopedia
Passed the House on January 9, 2007 (299-128 Roll call vote 015 , via Clerk.House.gov) Reported by the joint conference committee on July 25, ...

Hearing on “Reviewing the Rules and Regulations Implementing Federal Wage and Hour Standards.” - YouTube ...
SUBCOMMITTEE ON WORKFORCE PROTECTIONS hearing at 10:30 a.m. in room 2175 Rayburn House Office Building. Hearing on “Reviewing the Rules and Regulations ...


Iran, U.S., EU begin implementing historic nuclear deal
Iran unplugged banks of centrifuges involved in its most sensitive uranium enrichment work on Monday, prompting the United States and European ...

Iraq to talk with Syria on implementing AL deal
Iraq on Thursday agreed with the Arab League (AL) to try to convince Syria to implement the bloc's initiative in a bid to avoid economic sanctions ...

Iran says differences over implementing nuclear deal solved: negotiator
Montreal Gazette Iran says differences over implementing nuclear deal solved: negotiator People's Daily Online Global TimesChinadaily.com.cn ...

China, Kazakhstan to enhance cooperation by implementing Silk Road initiative
China, Kazakhstan to enhance cooperation by implementing Silk Road initiative

Guess? exec says company saw immediate improvements after implementing iPads in stores
BusinessInsider pointed us to an interview on OpenForum with CIO of clothing retailer Guess?, Michael Relich. The company implemented iPads for ...

Sheriff Joe Arpaio: MCSO implementing 'patriotic' campaign with US flag at each cell
The Maricopa County Sheriff’s Office announced it started a campaign to display U.S. flags on every cell among its jails. Any vandalism will ...

Change Has Come: OFCCP Publishes Final Rule Implementing Executive Order Prohibiting Federal Contractors ...
The U.S. Department of Labor’s Office of Federal Contract Compliance Programs (“OFCCP”) published a final rule today, implementing Executive ...

Resources last updated: 11/27/2015 10:18:19 PM