locked
ObjectList - see first element in object? RRS feed

  • Question

  • User296910172 posted
    I'm using the mobile control "ObjectList" for displaying email messages. I'm forming an ArrayList containing objects having four attributes: to, from, subject, and body. I'm binding the ObjectList to the ArrayList. This works, but the problem is the lines show up blank in the WAP browser. I'd like to see the "subject" in each line. How do I control what is displayed in an ObjectList when binding to an ArrayList which contains objects and not simple strings? Thanks for any assistance! Mark
    Thursday, January 20, 2005 12:55 AM

All replies

  • User-153924892 posted
    Please post the code. Thomas
    Thursday, January 20, 2005 2:45 AM
  • User-153924892 posted
    Post your code please. Thomas
    Thursday, January 20, 2005 2:58 AM
  • User296910172 posted
    Not sure if this will help, but here goes! Here's the code in the aspx page containing the ObjectList mobile web control: *************************** private void frmCheckEmail_Activate(object sender, System.EventArgs e) { ArrayList newmsgs = new ArrayList(); Pop myPop = new Pop(); myPop.popConnect(); int numMsgs = myPop.GetNumberOfNewMessages(); if (numMsgs >= 0) { if (numMsgs > 0) { newmsgs = myPop.GetNewMessages(""); IEnumerator msgenum = newmsgs.GetEnumerator(); while (msgenum.MoveNext() ) { Message req = (Message)msgenum.Current; } this.ObjectList1.DataSource = newmsgs; this.ObjectList1.DataBind(); } this.labNumMessages.Text = "Messages: "+numMsgs; } else this.labNumMessages.Text = "Cannot connect to mail server."; myPop.popDisconnect(); } *************************** GetNewMessages simply returns an Arraylist of these objects: public Message(string _to, string _from, string _subject, string _body){ to = _to; from = _from; body = _body; subject = _subject; } *************************** On the phone and on the Openwave WAP browser, the list of messages comes up all numbered, but each line is blank other than the number. I can read the message by choosing the line number on the phone. The problem is that I cannot see the subject or anything else in each line prior to choosing that message number and that item being displayed. Let me know if you need anything further. Thanks for any assistance, Mark
    Thursday, January 20, 2005 3:13 PM
  • User-153924892 posted
    I think for your requirements you should use a List not an ObjectList. In your ObjectList the LabelField seems to be missing therefore you get blank entrys. Use a List where the DataTextField is "Text" and the DataValueField is "Value". E. g. Text = to, Value = E-Mail Your ArrayList must have the following structure: newmsgs("to", "E-Mail") newmsgs("from", "E-Mail") newmsgs("body", "body") newmsgs("subject", "subject") I hope this helps. Thomas
    Thursday, January 20, 2005 5:10 PM
  • User-153924892 posted
    Replace "newmsgs" with "Message". Message has the two properties Text and Value: public Message(String Text, String Value) { this.Text = Text; this.Value = Value; } Thomas
    Friday, January 21, 2005 2:00 AM