×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Registered User
    Join Date
    Jul 2013
    Location
    chennai, TN
    Posts
    56

    I need to pass the list values from 1 page to another page

    Hi dude,

    In wp7, I need to pass the list values from 1 page to another page ,I have used PhoneApplicationService.Current.State to pass the data but i'm not able to recieve the data , i'm getting an invalidcastexception so any one knows p.s let me know ....

    if (PhoneApplicationService.Current.State.ContainsKey("xxxx"))
    {
    var x= PhoneApplicationService.Current.State["xxxx"];
    classmodel model = (classmodel )x; ** I'm getting invalidcastexception in this line.

    }

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    510

    Re: I need to pass the list values from 1 page to another page

    I'd suggest setting a breakpoint in Visual Studio on the line "var x = ..." and use the Watcher inside the Debugger to see what dynamic type x actually has after the assignment. Perhaps that sheds some light on what's going wrong.

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    548

    Re: I need to pass the list values from 1 page to another page

    I would write is as...

    Code:
    if (PhoneApplicationService.Current.State.ContainsKey("xxxx"))
    {
      var x= PhoneApplicationService.Current.State["xxxx"] as MyClass;
      
      x.blah;
      x.foo();
    }
    I would also make sure the result is not null;

  4. #4
    Registered User
    Join Date
    Jul 2013
    Location
    chennai, TN
    Posts
    56

    Re: I need to pass the list values from 1 page to another page

    hi...

    thank you guys ... i'm trying ....

  5. #5
    Registered User
    Join Date
    Jul 2013
    Location
    chennai, TN
    Posts
    56

    Re: I need to pass the list values from 1 page to another page

    hi...

    thank you..

    still I'm not getting an output I tried all ways, Is there any ways to get output.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: I need to pass the list values from 1 page to another page

    You may want to put a breakpoint there and check in the debugger what object you get.

  7. #7
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    548

    Re: I need to pass the list values from 1 page to another page

    Also, what code on the previous page are you using to send the data?

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    510

    Re: I need to pass the list values from 1 page to another page

    Given that he's getting the InvalidCastException on that line there is an object assigned there that is not of class "classmodel". If it was NULL the cast would work as long as he was casting to some Reference Type.

    Given that he's trying to transmit a list here most likely instead of type "classmodel" it will be an Array of type "classmodel" or a IList<classmodel> and he would simply have to cast it to that. The debugger would be the best way to find out what is actually arriving here (as something is arriving).

  9. #9
    Registered User
    Join Date
    Jul 2013
    Location
    chennai, TN
    Posts
    56

    I'm getting an invalid exception in xdocument --> wp7

    hi..

    Class1 obj = (Class1 )details; => I'm getting an invalid exception in this line.

    class1 => is name of the class file,
    details =>is the variable in xdocument,

    how to solve that invalid cast exception

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: I'm getting an invalid exception in xdocument --> wp7

    Your threads are merged now. While computer technology really evolves with an outstanding pace, this particular question still has the same answers as it had a week ago.

  11. #11
    Nokia Developer Champion
    Join Date
    Feb 2013
    Location
    Dublin, Ireland
    Posts
    548

    Re: I'm getting an invalid exception in xdocument --> wp7

    Quote Originally Posted by Murugan india View Post
    how to solve that invalid cast exception
    Go and look up (use your favourite search engine) what an Invalid Cast Exception is.

  12. #12
    Registered User
    Join Date
    Jan 2013
    Posts
    34

    Re: I need to pass the list values from 1 page to another page

    Exactly! It's not a case of knowing what's happening (because it's very clear what it is) but a case of knowing why/where it's happening. And the debugger is the best tool for it.

  13. #13
    Registered User
    Join Date
    Jul 2013
    Location
    chennai, TN
    Posts
    56

    Re: I'm getting an invalid exception in xdocument --> wp7

    hi.. wizard

    thank you

    Can u send me the link where was the question posted, I'm not able to find the question posted so P.s let me know

  14. #14
    Registered User
    Join Date
    Jul 2013
    Location
    chennai, TN
    Posts
    56

    Re: I'm getting an invalid exception in xdocument --> wp7

    hi....

    XDocument xdoc = XDocument.Parse(result);
    var details= from ack in xdoc.Descendants()
    where ack.Name =="Details"
    select ack;
    in variable details, i have an values

    myclass fd=(myclass )details; // I'm getting Invalidcast exception in this line, so can anyone help me out. how to solve it

    myclass => is the class name

  15. #15
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,021

    Re: I'm getting an invalid exception in xdocument --> wp7

    Are you trying to parse the xml data & then store the results in myclass (which contains set & get methods) ?, if yes then something like this may work:

    Code:
    XDocument xdoc = XDocument.Parse(result);
    var details= from ack in xdoc.Descendants("Details")
    
    select new myclass 
    {
    somevariable = ack .Element("element").Value // somevariable(setter-getter) is present in myclass
    }

Similar Threads

  1. How to pass objects from one page to another in widows phone 8
    By sunder.tinwar in forum Windows Phone General
    Replies: 6
    Last Post: 2013-07-13, 13:31
  2. Replies: 11
    Last Post: 2008-03-08, 18:07
  3. how to get database values from xhtml page
    By pbalix in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2007-10-10, 07:31
  4. Replies: 0
    Last Post: 2005-02-17, 06:15
  5. Why I can't pass the variable in JSP to next page?
    By msc73jxs in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2002-08-31, 14:35

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×