473,581 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SelectList. What am i doing wrong?

Hello,

I have the following:

SelectList targets;
UpdateModel(tar gets, 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 2154
On Tue, 16 Sep 2008 15:35:59 -0700, shapper <md*****@gmail. comwrote:
[...]
SelectList targets;
UpdateModel(tar gets, 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
2701
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 button, seems simple. I am using ALL visual controls (supposedly to simplify things. If I was not using the visual controls and calling an ExecuteNonQuery...
5
2903
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 basic wrong and for the life of me I can't see it. Please, somebody, cast your eyes over this and tell me what's wrong! First, the XSL stylesheet:...
8
2060
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 vertices and can do this multiple times on a sinlge vertex cluster. The problem I have been encoutering is that, if I select a second vertex...
0
1319
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 child controls (just a literal for testing) of my control is not being added to the page. Could someone tell me what am I doing wrong?
16
1902
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 simpler answer, by all means show me the light! What I'm trying to do is refresh the page at a timed interval ( actually redirect the page... )...
10
1788
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
1755
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 windows). Anyway, I just want to check that the program is valid before I see if I can find a way around a compiler bug. It might be...
8
7947
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
1156
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 SelectList(targets, "Value", "Key"); Given a MyVarKey = "_blank" how can I find in the list the Value for
0
7868
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7792
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8175
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5364
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3805
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1403
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.