Posted by: R Manimaran | February 23, 2007

Filling DropDownList using WebServices

In Web serives i have this web method

string cs = “provider=sqloledb;server=wkst3;” +“Integrated Security=SSPI;database=pubs;uid=sa;pwd=;”;[WebMethod(Description=”Fetch all authors.”)]

public DataSet GetAuthors(){OleDbDataAdapter adpt =

new OleDbDataAdapter(“SELECT * FROM authors”, cs);DataSet ds = new DataSet();adpt.Fill(ds);return ds;

In my aspx project first set the reference to that Web service using add web Reference.

In my  aspx page i place a dropdown control and Place this coding in page load,

localhost.Service1 ss=new localhost.Service1();ss.PreAuthenticate=false;ss.Credentials=System.Net.CredentialCache.DefaultCredentials;DataSet ds=ss.GetAuthors();


DropDownList1.DataValueField =”au_id”;


Here Service is my Webservice Name and localhost is the Name i give when we add reference.That’s all

my Dropdown list loaded with au_id.



  1. It is a good site through which i get my solutions regarding web service. I want to say thanks to the owner of the site and the code publisher.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: