Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6652597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:09:34+00:00 2026-05-26T01:09:34+00:00

I’m new in Silverlight and WCF. I’ve created a simple Silverlight application from where

  • 0

I’m new in Silverlight and WCF. I’ve created a simple Silverlight application from where I’m displaying the alert message box with data from list object collection after a wait of one second.

I’ve used WCF to connect to database. But I’m first adding all the database data in collection list, and then sending that list object to silverlight, which silverlight is iterating.

WCF Service code to connect to database in inserting the data in List collection:

public List<int> GetData()
        {
            List<int> list = new List<int>();
            using (SqlConnection connection = new SqlConnection())
            {
                connection.ConnectionString =
                    System.Configuration.ConfigurationManager.ConnectionStrings["sqlConnection"].ToString();
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.Text;
                    command.CommandText = "Select * from insertItem";
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            list.Add(reader.GetInt32(1));

                        }
                    }
                }

            }
            return list;
        }

Silverlight code to access list class from WCF service and displaying it in message box after a wait of one second:

Service1Client client = new Service1Client();
           client.GetDataCompleted += new EventHandler<GetDataCompletedEventArgs>(DisplayResults);
           client.GetDataAsync(1);

 private void DisplayResults(object sender, GetDataCompletedEventArgs e)
        {
            timer.Stop();
            ObservableCollection<int> list = e.Result;
            foreach (int i in list)
            {

                HtmlPage.Window.Alert(i.ToString());
                Thread.Sleep(1000);
            }

        }

Could anyone please tell me how can I display the data directly to silverlight from WCF services without waiting for first putting all the data in List class collection, and then displaying it? What could have been a better approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:09:35+00:00Added an answer on May 26, 2026 at 1:09 am

    I am not sure if you are asking if what you are doing is best practice. Yes, you need to collect data from a database first to be able to sent it through a webservice to your caller. You did that, and thats fine. You could have used some mapper maybe, but as that part works, you should be fine. Why change it? What is the problem? Is it slow? Must be something different, maybe its too much data you are trying to send? Try putting some constraints in, only retrieve the first 15 items, and continue requesting more as your user browses through the results.

    If you are concerned that it takes too long to add stuff to a list, dont be, that is probably not the problem but rather the size of data requested.

    To display the data, you just add a capable control and set the datasource to the list. Done!

    Here is a walkthrough, and here is an article covering that topic by your silverlight Guru no1, ScottGu himself. Should help you getting started.

    If you really want to change how you access your data, you might as well take a look at RIA Services for Silverlight, though that is considered an advanced technique.

    If that doesnt help you, you might want to refine your question. So, what do you think needs to be changed in your current design? What doesnt work out as expected?

    EDIT: After you have answered my comment i think you might achieve what you want to do by implementing a Duplex Service.

    This topic describes how to create a duplex Windows Communication Foundation (WCF) service that can communicate with a Silverlight client. A duplex service maintains a callback channel to the Silverlight client, which allows the service to make calls to the client. Duplex services have numerous applications including, for example, a chat server for instant messaging or a monitoring service that sends notifications to the client. This sample provides a service that allows a client to order a specified number of product items by name. It simulates processing the order and then calls back to the client with status on the order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.