.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

There is no ViewData item of type 'IEnumerable' that has the key 'Carrera'.

Posted By:      Posted Date: September 06, 2010    Points: 0   Category :ASP.Net
When running the HttpGet action, it works fine. But when I run the HttpPost action, I recieve the error in the title. Can anyone help me out? Is it because the HttpPost doesn't have a ViewData declared? Thanks for the help.[HttpGet] public ActionResult Crear() { CarreraRepository carreraRepository = new CarreraRepository(); var carreras = carreraRepository.FindAll().OrderBy(x => x.Nombre); var carrerasList = new SelectList(carreras, "ID", "Nombre"); ViewData["Carreras"] = carrerasList; Materia materia = new Materia(); return View(materia); } [HttpPost] public ActionResult Crear(Materia materia, FormCollection values) { if (ModelState.IsValid) { repo.Add(materia); repo.Save(); return RedirectToAction("Index"); } return View(materia); }

View Complete Post

More Related Resource Links

DropDownList problems : The ViewData item that has the key 'userTYPE_id_user_type' is of type 'Sy

Hello,I've been searching for that problem for hours...I have two table :          -user          -userTypeI'm trying to create a user, wich as a column id_userType, so I'm trying to do a dropdownlist with the userType List I've that error code : The ViewData item that has the key 'userTYPE_id_user_type' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'. // // GET: /User/Create public ActionResult Create() { //Send to the view, the userTypeList IEnumerable<SelectListItem> userTypeList = new SelectList(_userRepository.FindAllUserType().Distinct().ToList(), "id_user_type", "Description"); ViewData["userType_id_user_type"] = userTypeList; return View(); } here the post controller // // POST: /User/Create [HttpPost] public ActionResult Create(users user) { if (ModelState.IsValid) { try { _userRepository.addUser(user); _userRepository.save(); return RedirectToAction("Index"); } catch { return Vie

Create buttons for "new item" which create a new page of a specific content type

We have a Pages library (wiki) which supports a few content types (and page layout associated). We want to enable users to click a button for example of "new custom enterprise wiki page" - so a new page of content type article will be open in edit mode. Can someone help how to develop? (it has to mimic the behavior that happens when user creates new page from the Ribbon or Site actions and has to choose the content type, it also has to keep the new page in edit mode and not just create it).  

IEnumerable Type Casting

Hello Everyone,  The following line is giving me an InvalidCastException when trying to convert to IEnumerable type, even though I have implemented IEnumerable interface.  Return New CountryInfo(CountryCodes(i), CountryNames(i)) (also in bold below)Imports System Imports Gaia.WebWidgets.HtmlFormatting Imports System.Collections.Generic Imports System.Globalization Public Class CountryInfo Implements IEnumerable Property Name As String Property Code As String Public Sub New(ByVal code As String, ByVal name As String) _Code = code _Name = name End Sub Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator Return CType(Me, IEnumerator) End Function Public Class SearchResult Private ReadOnly _countries As List(Of CountryInfo) Private ReadOnly _query As String Friend Sub New(ByVal countries As List(Of CountryInfo), ByVal query As String) _countries = countries _query = query End Sub Public ReadOnly Property IsEmpty As Boolean Get Return _countries.Count = 0 End Get End Property Public ReadOnly Property Countries As List(Of CountryInfo) Get Return _countries End Get End Property Public Function Bui

How to display TreeViewItems different ways based on the item type under a single node?

Hi, I am having trouble trying to display hiearchical data under each node in two different ways depending on the data.  I hope someone will be able to provide me some help on this since I am rather new to WPF development. Maybe I am going about this all wrong but for now, I am trying to create a customized TreeView to represent data similar to the xml I provided in the code below.  The <ItemsPresenter/> instances listed in the code are not exactly doing what I need.  I will probably need to filter the content that I list with each of the two <ItemsPresenter/> tags based on the type of each item although I have no idea if this is possible.   <Window x:Class="Wpf_treeview_testing.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <!-- * The "xmlData" describe roughly the type of data that I require visual representaion of. * Since I could not find a WPF Control that will present a Hierachical Data Template close to what we need, I am trying to setup a TreeView to represent this information by using a ControlTemplate for TreeViewItem. * The preferred result is to present different items types in

Issue with Announcement content type and adding a new item



I have the following issue with the (Silverlight?) form to add a new item:If the screen has many fields so scroll bars appear (i.e. it's longer than the screen), you can move up and down. YET, if you press to attach a file, the scroll bars dissapear, so you can't see the rest of the form.

To reproduce: 

a) make an annoucement list

b) Add a choice field, add many choises and enable multiple values - in order to have a longer-than-the-screen input form.

c) Go to the list , press add-new-item and attach a file: After that, you won;t be able to see all the input form.



http 400 Error when performing item upload after setting custom edit form on content type



What I am trying to do is create custom edit forms for different content types within the same document library.....so basically I have done the following:

  • I have created two site content types and reconfigured my library to use CT's. 
  • I then connected to my site using SPD. 
  • When examining my library I can see that I have the two CT that I added earlier.  I then created a new editform for one the CTs using the top ribbon menu and in the drop down box associated it to the CT.  I did not select this as the default form for the library.
  • I then updated the library CT (not site CT) with the url to form in the editform properties.

When I create a document and edit the properties it works fine - totally as expected.  However when I upload a document the default EditForm for the library is used and I can select the CT to associate the document to.  When I choose the CT with the custom form the new edit form is not found and I get a page not found error - http 400.

The full url for this library is is http://XXXX/functions/ehs/CSI

So the URL I have used is /functions/ehs/CSI/Forms/EditForm2.aspx (EditForm2.aspx) is my form and this is fine.  I have even used CSI/Forms/EditForm2.aspx and this works...  BUT ne

Using the generic type 'System.Collections.Generic.IEnumerable' requires '1' type arguments



I'm trying to create a control out of a class I found, and one of the overridden functions is the following:

protected override void PerformDataBinding(IEnumerable data)

However, when I try to build the control I'm getting the error as shown in the subject. I've tried searching, and it seems the signature for the original function matches the one I have, and all other solutions I've seen uses the same signature.

Anyone able to help out?

Add new item link to create a no-default content type item


I have a contacts list in which there is a company and person content type. The default content type is person, given they will be the most commonly created item. However, I want to create a link on a different page that links to create a company. The link created correctly launches the company contact form, but for some reason creates the contact as a person contact (i.e. the default) instead of a company content type.

My link is: https://MyServer/MySite/Lists/MyList/NewCompanyContact.aspx?List=0b73f0cb%2Deb48%2D4a25%2Da817%2Dc89f930e19a5&RootFolder=%2FBusinessDevelopment%2FLists%2FContacts&ContentTypeId=0x01007B29F47C6BF470468E8EA02DD8570DFF001DA7CBDD0D967F498114C805487BEA38&IsDlg=1 

Am I missing something?

Cheers, Theo

Using Additional Fields from External Content Type in InfoPath 2010 External Item Picker


Hello, we've created an external content type for our store locations. Each location in the content type has a name, id, manager, region and so on. When we use this BCS content type as a field in a list, we are given the option to "Add a column to show each of these additional fields"

What would the equivalent be in an InfoPath form? When we add an External Item Picker to a form a number of fields are included in the form's data source, including a repeating group called BDCEntity with the following fields:

  • EntityDisplayName
  • EntityInstanceReference
  • EntityId1
  • EntityId2
  • EntityId3
  • EntityId4
  • EntityId5

Entity display name appears to be what we configure as the Display Field Name in the picker properties, and the EntityId1 is the location ID, which is the identifier on the external content type. EntityId2-5 are all blank.

We use region and other location attributes in workflows so how can we access all these other fields?

Thanks for your time.

Peter Newhook SharePoint posts on my blog

Determining the Content Type of a new item


I seem to have painted myself into a corner. The short story: I have a list that supports three different content types, all of which share a lookup column called Template. As a new item is added I want to be able to filter the Template items based on which content type is being applied. Is there any way to determine the content type before the new item form has finished loading? If I can determine what the content type is I'm thinking I could use JQuery to remove the Template items I don't want. 


TreeSelector : playing with generics and type inference

create a generic way to define a selection starting from a tree of objects, the most simpler way as possible.

Let's start with the beginning...
Here is a very simple little interface defining a node of the tree, basically, a value and the references to the child nodes.

UnTyped DataSets and Strongly Type DataSets

We all are use datasets as a means of carrier of data from one layer to another. Most of the time we are using weakly typed datasets. In this article I will explain the differences between weakly typed datasets and strongly type datasets

Gmail style multiple Sign-in type combo...is it possible in asp.net?


I am developing a multi-company application and want my users to give the functionality like the following to switch companies.


Is this possible? then how?

Please help


Missing 'new item templates'


 Hi all,

          I am a 'newbie' to VWD and I am slowly working through the Basic Walkthrough Help files, and learning plenty along the way.

However, when I tried to create a new database in the LINQ control walkthrough I found that the option to create a new database is missing, and further investigation has found that many other new item templates are missing.

I am using a brand new machine with Windows 7 Ultimate and have enabled IIS and .NET from Control Panel-Programs-Turn Windows Features On-Off. I used the WPI to install all basic elements eg. IIS Components, SQL Server Express.

The only 'new item templates' I have when I right-click the App_Data Folder and choose 'new item' are:-

ADO.NET Data Service

AJAX Enabled WCF Service

Dynamic Data Field

SQL Server Database

Text File

XML File

Does anyone know where I have gone wrong.


Michael J. Hill

Type or namespace error.


A couple of days ago I started getting an unusual behavior when compiling Website projects. I have referenced class libraries added to my bin folder that are also correctely referenced in using statements in my aspx.cs code behind. When I compile, I get the 

Error 4 The type or namespace name 'CommonClassLibrary' could not be found (are you missing a using directive or an assembly reference?) C:\Dev\Fiscal_Portal\Implementation\FMS Portal Site_new\App_Code\BLL\DataTables.cs 1 7 C:\...\FMS Portal Site_new\

The type or namespace name 'CommonClassLibrary' could not be found (are you missing a using directive or an assembly reference?)

error message that would typically be received when the dll has not been added as a reference or added in a using statement.

I can eliminate the error by adding an


Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

The number of members in the conceptual type ... does not match with the number of members on the ob



I've added a scalar property to an entity and now ASP.NET Dynamic Data scaffolding throws this error:

The number of members in the conceptual type 'TrainingModel.Users' does not match with the number of members on the object side type 'TrainingModel.Users'. Make sure the number of members are the same.

This happens at the following line in global.asax:
model.RegisterContext(typeof(TrainingModel.TrainingEntities), new ContextConfiguration() { ScaffoldAllTables = true });

Please help!

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend