How do I call a method contaning an array and display it on a web page

Ptolemy

New member
Joined
Jul 5, 2014
Messages
2
Programming Experience
Beginner
I have this method RaceDaySimple[] raceDay that I'm trying to call:
C#:
public partial class RaceDayCalendarSimple : object, System.ComponentModel.INotifyPropertyChanged {
        
        private RaceDaySimple[] raceDayField;
        
        private AtgDateTime timestampField;
        
        /// <remarks/>
        [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true, Order=0)]
        /*==> */public RaceDaySimple[] raceDay {
            get {
                return this.raceDayField;
            }
            set {
                this.raceDayField = value;
                this.RaisePropertyChanged("raceDay");
            }
        }


    }

I want to display the content on a web page so I have tried with this:
C#:
namespace WebServiceClient
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            InformationServiceReference.PartnerInfoServicePortClient pbs = new InformationServiceReference.PartnerInfoServicePortClient();
            pbs.ClientCredentials.UserName.UserName = "Username";
            pbs.ClientCredentials.UserName.Password = "Password";


           test.InnerHtml = pbs.fetchRaceDayCalendarSimple().raceDay[0].ToString(); // Trying to call the method by doing this
        }
    }
}

But the only thing that gets displayed is this:

WebServiceClient.InformationServiceReference.RaceDaySimple

So actually what I want to be displayed is the informaton that this method provides. It should Fetch basic information about some racedays/meetings.

Like this:

RaceDayInfo.PNG

I guess
C#:
test.InnerHtml = pbs.fetchRaceDayCalendarSimple().raceDay[0].ToString();
...wouldn't be enough to display everything but I think I should at least get some kind of value displayed.

So how do I access this method properly and display the information about the racedays/meetings, that this web service provides?
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,269
Location
Sydney, Australia
Programming Experience
10+
What exactly do you expect that ToString call to do? It doesn't magically know how you want to display the info contained in an object. By default, the ToString method simply returns the name of the type of the object, which is exactly why that's what you see. For any ToString method to do differently, the author of the type has to override the ToString method and implement the logic to construct the desired String.

What you're looking to display is far too complex to be considered appropriate for a ToString method though. What you should be doing is getting the individual property values and displaying them each in their own control. You could use String.Format or something like that to generate a single String to display in a single control but that's a lot of information for a single control.
 
Top Bottom