473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

SelectList. What am i doing wrong?

Hello,

I have the following:

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?

Thanks,
Miguel
Sep 16 '08 #1
1 2152
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
Sep 17 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Aaron Ackerman | last post by:
I cannot a row to this bound DataGrid to SAVE MY LIFE! I have tried everything and I am at a loss. The using goes into add mode with the add button adds his data then updates with the update...
5
by: Simon Brooke | last post by:
This is supposed to be a very simple XSL stylesheet to strip styling information out of HTML documents - it could not be more basic. And yet, it doesn't work. I'm obviously getting something very...
8
by: watkinsdev | last post by:
Hi, I have created a mesh class in visual studio 6.0 c++. I can create a device, render objects and can edit the objects by for instancnce selecting a cluster of vertices and processing the...
0
by: shapper | last post by:
Hello, I am creating a class with a control. I compiled the class and used it on an Asp.Net 2.0 web site page. I can see the begin and end tags of my control (<oland </ol>) but somehow the...
16
by: SirG | last post by:
I'm looking for an explanation of why one piece of code works and another does not. I have to warn you that this is the first piece of Javascript I've ever written, so if there is a better way or a...
10
by: DavidSeck.com | last post by:
Hi, I am working with the Facebook API right now, an I have kind of a problem, but I don't know what I am doing wrong. So I have a few arrays, f.ex.: User albums: array(2) {
34
by: raphfrk | last post by:
This program should copy one file onto the other. It works if I compile it with gcc to a cygwin program. However, if I compile it with the -mno-cygwin option, it doesn't work (this targets native...
8
by: shapper | last post by:
Hello, I am creating a select list as follows: new SelectList(new { "a", "b"}) How can I create the same list but with different name and value for each item? Thanks,
0
by: shapper | last post by:
Hello, I created the following SelectList: var targets = new Dictionary<string, string>(); targets.Add("New Window", "_blank"); targets.Add("SameWindow", "_self"); viewData.Targets = new...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.