However the actual solution is to not do the "new", just do "Select p.CategoryID". You will probably then need to use kategoryid.First() to get the number, as your query will return a collection of numbers as it doesn't know there is only one. There will
be some way of making sure the query only returns the first item if that is what you want, but as I said I'm no vb.net expert.
AidyF
Star
9204 Points
1570 Posts
Re: how to show the result in label
Apr 30, 2012 09:48 PM|LINK
I'm not VB.net expert, but your "select new with {p.CategoryID} is returning an anonymous object with a property called CategoryID. So you would do;
Label1.Text = kategoryid.First().CategoryID.ToString()
However the actual solution is to not do the "new", just do "Select p.CategoryID". You will probably then need to use kategoryid.First() to get the number, as your query will return a collection of numbers as it doesn't know there is only one. There will be some way of making sure the query only returns the first item if that is what you want, but as I said I'm no vb.net expert.