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 4596218
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:05:02+00:00 2026-05-21T23:05:02+00:00

History: I have a small site in PHP which I wanted to make a

  • 0

History: I have a small site in PHP which I wanted to make a better front end for. Having looked around, spending an hour or so on each of FlashBuilder etc., I found Silverlight 4 the quickest to get moving with, but I have hit an issue.

I have a class for simplicity

 public partial class data
        {
            public String Software;
            public int OK;
            public int warn;
            public int falsepos;
            public int failed;
            public int total;
        }

I then load the class using a call to my service going something like:

    [OperationContract]
    public List<data> GetSum(){
     String sql="SELECT Software, OK, warn, falsepos, failed from sum";
        List<data> res = new List<data>();
            if (!DBConnect()) { throw new Exception("Unable to contact Database"); }

            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = new SqlCommand(sql, _sqlConnection);
            DataSet ds = new DataSet();
            da.Fill(ds);
            _sqlConnection.Close();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                data d = new data();
                d.Software = dr["software"].ToString();
                d.OK  = Int16.Parse(dr["OK"].ToString());
                d.warn  = Int16.Parse(dr["Warning"].ToString());
                d.falsepos = Int16.Parse(dr["False Positive"].ToString());
                d.failed = Int16.Parse(dr["Failed"].ToString());
                d.total = d.OK+d.warn+d.falsepos+d.failed;
                res.Add(d);
            }
            return res;}

Now, that compiles fine, except, the moment I add the foreach, it starts falling apart,

private void Summary(object Sender, ServiceProxy.GetSumCompletedEventArgs e)
{
    foreach (data d in e.Result)
    {

    }
}

The moment I go to parse through the list as a result, it says

Error    2    foreach statement cannot operate on variables of type 'SilverlightApplication1.ServiceProxy.GetSumResponse' because 'SilverlightApplication1.ServiceProxy.GetSumResponse' does not contain a public definition for 'GetEnumerator'    C:\Users\me\Documents\Visual Studio 2010\Projects\SilverlightApplication1\SilverlightApplication1\Page1.xaml.cs    52    13    SilverlightApplication1

Now, I’ve looked around and read and seen a number of things, now, a very very similar function which just returns a list of servernames, works. Because I guess it’s of type String, however, I understand it’s not generated the how to read the single item within the list, but this is bugging me. I just want to return a simple list of stuff. Can someone please point me in the right direction?

I’m sure it’s something simple. Like an attribute, or something, but this seems silly that I can’t find the answer, be kind, I’ve only been looking at Silverlight for a couple of hours.

  • 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-21T23:05:03+00:00Added an answer on May 21, 2026 at 11:05 pm

    Following the lines of this answer

    You can try

    [DataContract]
    public class DataResult
    {
        [DataMember]
        public List<data> DataList{ get; set; }
    
        DataResult(List<data> dataList)
        { 
            DataList = dataList;
        }
    
    }
    
    [OperationContract]
    public List<data> GetSum(){
        ...
        ...
    
        return DataResult(res);
    }
    
    
    
    private void Summary(object Sender, ServiceProxy.GetSumCompletedEventArgs e)
    {
        foreach (data d in e.Result.DataList)
        {
    
        }          
    }
    

    and to display the list to a grid, you can do

    DataGrid1.ItemsSource = e.Result.DataList;
    

    and that should do it if your columns are configured properly or set to auto generate.

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

Sidebar

Related Questions

I have a controller which has a method called history class UsersController < ApplicationController
I have a small java utility application which performs tasks on remote computers. This
I have a history table like below CREATE TABLE [dbo].[t_PettyCash_History] ( [TableName] [varchar] (500)
I have 2 tables product and history product table: id name type price location
I have a database that contains a history of product sales. For example the
I have a database that keeps record history. For each update to a record,
I have a database for tracking customer purchases over history. One of my forms
I have to remove a branch from svn history for good. Normally I would
I have some Java code which looks roughly like this: String urlString = ftp://polar.ncep.noaa.gov/pub/history/waves/multi_1.glo_30m.dp.200601.grb2;
I would like to have this behavior in a task history stack: First task

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.