On Tue, 16 Sep 2008 15:35:59 -0700, shapper <md*****@gmail.comwrote:
[...]
SelectList targets;
UpdateModel(targets, new[] { "Targets" });
I get an error on second line over targets saying:
Use of unassigned local variable 'targets'
I think I should do something as:
SelectList targets = new SelectList();
However, this is not possible. What am I doing wrong?
Unfortunately, as near as I can tell, the SelectList class isn't a part of
the release .NET Framework, but rather is going to be included in a future
release. So, for those of us who haven't installed the technology preview
that includes it, it's difficult to answer your question.
But, yes...you most certainly need to initialize your "targets" variable
before you pass it to something. How best to do that would depend on the
SelectList class itself. Just looking at Scott Guthrie's blog entry
describing it, it appears that you need to pass to the constructor of
SelectList a collection, along with several other pieces of information.
If you can provide a link to some documentation for the class (I was
unable to find anything on MSDN, other than the information about the tech
preview itself), then I suppose someone might be able to help you navigate
the docs and come up with a solution. Or, if you're lucky, someone
reading this forum is familiar with the new MVC stuff in ASP.NET. But
otherwise, you may not find much help here (the ASP.NET newsgroup might be
more useful though).
Pete