Search Results

Search found 13838 results on 554 pages for 'disconnected model'.

Page 51/554 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • BindAttribute, Exclude nested properties for complex types

    - by David Board
    I have a 'Stream' model: public class Stream { public int ID { get; set; } [Required] [StringLength(50, ErrorMessage = "Stream name cannot be longer than 50 characters.")] public string Name { get; set; } [Required] [DataType(DataType.Url)] public string URL { get; set; } [Required] [Display(Name="Service")] public int ServiceID { get; set; } public virtual Service Service { get; set; } public virtual ICollection<Event> Events { get; set; } public virtual ICollection<Monitor> Monitors { get; set; } public virtual ICollection<AlertRule> AlertRules { get; set; } } For the 'create' view for this model, I have made a view model to pass some additional information to the view: public class StreamCreateVM { public Stream Stream { get; set; } public SelectList ServicesList { get; set; } public int SelectedService { get; set; } } Here is my create post action: [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include="Stream, Stream.Name, Stream.ServiceID, SelectedService")] StreamCreateVM viewModel) { if (ModelState.IsValid) { db.Streams.Add(viewModel.Stream); db.SaveChanges(); return RedirectToAction("Index", "Service", new { id = viewModel.Stream.ServiceID }); } return View(viewModel); } Now, this all works, apart from the [Bind(Include="Stream, Stream.Name, Stream.ServiceID, SelectedService")] bit. I can't seem to Include or Exclude properties within a nested object.

    Read the article

  • Where should 'CreateMap' statements go?

    - by jonathanconway
    I frequently use AutoMapper to map Model (Domain) objects to ViewModel objects, which are then consumed by my Views, in a Model/View/View-Model pattern. This involves many 'Mapper.CreateMap' statements, which all must be executed, but must only be executed once in the lifecycle of the application. Technically, then, I should keep them all in a static method somewhere, which gets called from my Application_Start() method (this is an ASP.NET MVC application). However, it seems wrong to group a lot of different mapping concerns together in one central location. Especially when mapping code gets complex and involves formatting and other logic. Is there a better way to organize the mapping code so that it's kept close to the ViewModel that it concerns? (I came up with one idea - having a 'CreateMappings' method on each ViewModel, and in the BaseViewModel, calling this method on instantiation. However, since the method should only be called once in the application lifecycle, it needs some additional logic to cache a list of ViewModel types for which the CreateMappings method has been called, and then only call it when necessary, for ViewModels that aren't in that list.)

    Read the article

  • Why does my data not pass into my view correctly?

    - by dmanexe
    I have a model, view and controller not interacting correctly, and I do not know where the error lies. First, the controller. According to the Code Igniter documentation, I'm passing variables correctly here. function view() { $html_head = array( 'title' => 'Estimate Management' ); $estimates = $this->Estimatemodel->get_estimates(); $this->load->view('html_head', $html_head); $this->load->view('estimates/view', $estimates); $this->load->view('html_foot'); } The model (short and sweet): function get_estimates() { $query = $this->db->get('estimates')->result(); return $query; } And finally the view, just to print the data for initial development purposes: <? print_r($estimates); ?> Now it's undefined when I navigate to this page. However, I know that $query is defined, because it works when I run the model code directly in the view.

    Read the article

  • How to nest joins with CakePHP?

    - by Daren Thomas
    I'm trying to behave. So, instead of using following SQL syntax: select * from tableA INNER JOIN tableB on tableA.id = tableB.tableA_id LEFT OUTER JOIN ( tableC INNER JOIN tableD on tableC.tableD_id = tableD.id) on tableC.tableA_id = tableA.id I'd like to use the CakePHP model->find(). This will let me use the Paginator too, since that will not work with custom SQL queries as far as I understand (unless you hardcode one single pagination query to the model which seems a little inflexible to me). What I've tried so far: /* inside tableA_controller.php, inside an action, e.g. "view" */ $this->paginate['recursive'] = -1; # suppress model associations for now $this->paginate['joins'] = array( array( 'table' => 'tableB', 'alias' => 'TableB', 'type' => 'inner', 'conditions' => 'TableB.tableA_id = TableA.id', ), array( 'table' => 'tableC', 'alias' => 'TableC', 'type' => 'left', 'conditions' => 'TableC.tableA_id = TableA.id', 'joins' = array( # this would be the obvious way to do it, but doesn't work array( 'table' => 'tableD', 'alias' => 'TableD', 'type' => 'inner', 'conditions' => 'TableC.tableD_id = TableD.id' ) ) ) ) That is, nesting the joins into the structure. But that doesn't work (CakePHP just ignores the nested 'joins' element which was kind of what I expected, but sad. I have seen hints in comments on how to do subqueries (in the where clause) using a statement builder. Can a similar trick be used here?

    Read the article

  • Model Object called in NSOutlineView DataSource Method Crashing App

    - by Alec Sloman
    I have a bewildering problem, hoping someone can assist: I have a model object, called Road. Here's the interface. @@@ @interface RoadModel : NSObject { NSString *_id; NSString *roadmapID; NSString *routeID; NSString *title; NSString *description; NSNumber *collapsed; NSNumber *isRoute; NSString *staff; NSNumber *start; NSArray *staffList; NSMutableArray *updates; NSMutableArray *uploads; NSMutableArray *subRoads; } @property (nonatomic, copy) NSString *_id; @property (nonatomic, copy) NSString *roadmapID; @property (nonatomic, copy) NSString *routeID; @property (nonatomic, copy) NSString *title; @property (nonatomic, copy) NSString *description; @property (nonatomic, copy) NSNumber *collapsed; @property (nonatomic, copy) NSNumber *isRoute; @property (nonatomic, copy) NSString *staff; @property (nonatomic, copy) NSNumber *start; @property (nonatomic, copy) NSArray *staffList; @property (nonatomic, copy) NSMutableArray *updates; @property (nonatomic, copy) NSMutableArray *uploads; @property (nonatomic, copy) NSMutableArray *subRoads; - (id)initWithJSONObject:(NSDictionary *)JSONObject; @end This part is fine. To give you some background, I'm translating a bunch of JSON into a proper model object so it's easier to work with. Now, I'm trying to display this in an NSOutlineView. This is where the problem is. In particular, I have created the table and a datasource. - (id)initWithRoads:(NSArray *)roads { if (self = [super init]) root = [[NSMutableArray alloc] initWithArray:roads]; return self; } - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { if (item == nil) return root.count; return 0; } - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item { return NO; } - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item { if (item == nil) item = root; if (item == root) return [root objectAtIndex:index]; return nil; } - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { return [item title]; } In the final datasource method, it attempts to return the "title" string property of the model object, but for some reason crashes each time. I have checked that the method is taking in the correct object (I checked [item class] description], and it is the right object), but for some reason if I call any of the objects accessors the app immediately crashes. This is totally puzzling because in the init method, I can iterate through root (an array of RoadModel objects), and print any of its properties without issue. It is only when I'm trying to access the properties in any of the datasource methods that this occurs. I wonder if there is something memory-wise that is going on behind the scenes and I am not providing for it. If you can shed some light on to this situation, it would be greatly appreciated! Thanks in advance!

    Read the article

  • MVC 2 - Name Attributes on HTML Input Field when using Parent/Child Entities

    - by Click Ahead
    Hi All, I'm pretty new to MVC 2 using the Entity Framework. I have two tables Company {ID int identity PK,Name nvarchar} and User {ID int identity PK,UserName nvarchar,CompanyID int FK}. A Foreign Key exists between User and Company. I generated my ADO.NET Entity Data Model, a Controller and a view to insert a record. My HTML form has the fields Company and UserName and the idea is when I click save a Company and User is inserted into the database. Sounds straight forward right! My question is as follows: I created a strongly-typed view derived from my 'User' entity. I'm using the the html helper Html.TextBoxFor(model = model.Organisation.Name) but the html name attribute for this input field is 'Organisation.Name'. My problem with this is that the dot throws up all sorts of issues in JQuery, which sees this as a property. If I want to change the name I read that I can use DataAnnotations but because I used the Entity Designer this involves using Buddy Classes. Seems like a bit of overkill just to change the html name attribute on this input field. Am I approaching this the right way or am I missing something here? Thanks for the help !

    Read the article

  • How do I get started designing and implementing a script interface for my .NET application?

    - by Peter Mortensen
    How do I get started designing and implementing a script interface for my .NET application? There is VSTA (the .NET equivalent of VBA for COM), but as far as I understand I would have to pay a license fee for every installation of my application. It is an open source application so this will not work. There is also e.g. the embedding of interpreters (IronPython?), but I don't understand how this would allow exposing an "object model" (see below) to external (or internal) scripts. What is the scripting interface story in .NET? Is it somehow trivial in .NET to do this? Background: I have once designed and implemented a fairly involved script interface for a Macintosh application for acquisition and analysis of data from a mass spectrometer (Mac OS, System 7) and later a COM interface for a Windows application. Both were designed with an "object model" and classes (that can have properties). These are overloaded words, but in a scripting interface context object model is essentially a containment hiarchy of objects of specific classes. Classes have properties and lists of contained objects. E.g. like in the COM interfaces exposed in Microsoft Office applications, where the application object can be used to add to its list of documents (with the side effect of creating the GUI representation of a document). External scripts can create new objects in a container and navigate through the content of the hiarchy at any given time. In the Macintosh case scripts could be written in e.g. AppleScript or Frontier. On the Macintosh the implementation of a scripting interface was very complicated. Support for it in Metroworks' C++ class library (the name escapes me right now) made it much simpler.

    Read the article

  • How to maintain an ordered table with Core Data (or SQL) with insertions/deletions?

    - by Jean-Denis Muys
    This question is in the context of Core Data, but if I am not mistaken, it applies equally well to a more general SQL case. I want to maintain an ordered table using Core Data, with the possibility for the user to: reorder rows insert new lines anywhere delete any existing line What's the best data model to do that? I can see two ways: 1) Model it as an array: I add an int position property to my entity 2) Model it as a linked list: I add two one-to-one relations, next and previous from my entity to itself 1) makes it easy to sort, but painful to insert or delete as you then have to update the position of all objects that come after 2) makes it easy to insert or delete, but very difficult to sort. In fact, I don't think I know how to express a Sort Descriptor (SQL ORDER BY clause) for that case. Now I can imagine a variation on 1): 3) add an int ordering property to the entity, but instead of having it count one-by-one, have it count 100 by 100 (for example). Then inserting is as simple as finding any number between the ordering of the previous and next existing objects. The expensive renumbering only has to occur when the 100 holes have been filled. Making that property a float rather than an int makes it even better: it's almost always possible to find a new float midway between two floats. Am I on the right track with solution 3), or is there something smarter?

    Read the article

  • How to validate properties across Models without repeating the validation logic

    - by Mano
    Hello All, I am building a ASP.NET Mvc app. I have a Data model say User public class user { public int userId {get; private set}; public string FirstName {get; set;} } The validation to be done is that the firstname cannot exceed 50 characters. I have another presentation model in which i have the property FirstName too. I do not want to repeat the validation logic in both the models. I want to have it in one place and that should be it. I can do it in a simpler way by adding a function which can be called while setting the property like private string firstName; public string FirstName { get { return firstName; } set { if (PropertyValidator.ValidName(value)) // assuming ValidName exists and it will throw an exception if the value is not valid { firstName = value; } } } But I am looking for something much simpler so that I do not need to add this for every property I need to have it validated. I looked at ValidationAttribute but then again I can validate this only from a controller (ModelState.IsValid). Since this model could be used by some other type of apps like console app, I could not choose that. But if there is a way to use the Mvc's ModelState.IsValid from outside of a controller, that would be awesome. Any suggestions are greatly appreciated. Thanks!!

    Read the article

  • ASP.NET MVC3 ValueProvider drops string input to a double property

    - by Daniel Koverman
    I'm attempting to validate the input of a text box which corresponds to a property of type double in my model. If the user inputs "foo" I want to know about it so I can display an error. However, the ValueProvider is dropping the value silently (no errors are added to the ModelState). In a normal submission, I fill in "2" for the text box corresponding to myDouble and submit the form. Inspecting controllerContext.HttpContext.Request.Form shows that myDouble=2, among other correct inputs. bindingContext.ValueProvider.GetValue("myDouble") == 2, as expected. The bindingContext.ModelState.Count == 6 and bindingContext.ModelState["myDouble"].Errors.Count == 0. Everything is good and the model binds as expected. Then I fill in "foo" for the text box corresponding to myDouble and submitted the form. Inspecting controllerContext.HttpContext.Request.Form shows that myDouble=foo, which is what I expected. However, bindingContext.ValueProvider.GetValue("myDouble") == null and bindingContext.ModelState.Count == 5 (The exact number isn't important, but it's one less than before). Looking at the ValueProvider, is as if myDouble was never submitted and the model binding occurs as if it wasn't. This makes it difficult to differentiate between a bad input and no input. Is this the expected behavior of ValueProvider? Is there a way to get ValueProvider to report when conversion fails without implementing a custom ValueProvider? Thanks!

    Read the article

  • codeigniter and JSON

    - by ole
    Hello all i having a problem that it only get 1 value in my database and its my title and i want to show content and username from the same table to. here is my JSON kode <script type="text/javascript"> $.getJSON( 'ajax/forumThreads', function(data) { alert(data[0].overskrift); alert(data[0].indhold); } ); </script> my controller <?php class ajax extends Controller { function forumThreads() { $this->load->model('ajax_model'); $data['forum_list'] = $this->ajax_model->forumList(); if ($data['forum_list'] !== false) { echo json_encode($data['forum_list']); } } } my model fle <?php class ajax_model extends Model { function forumList() { $this->db->select('overskrift', 'indhold', 'brugernavn', 'dato'); $this->db->order_by('id', 'desc'); $this->db->limit(5); $forum_list = $this->db->get('forum_traad'); if($forum_list->num_rows() > 0) { return $forum_list->result_array(); } else { return false; } } }

    Read the article

  • Is it possible to connect slots of a model object to the GUI in QT4 -Designer?

    - by Robert0
    So I try to build a Model-View window using QTDesigner and C++. For that reason I created a QOBject derived class as my model. It provides slots and signals to access it like: setFileName(QString) or fileNameChanged(QString). I got a little into using signal drag and drop in QTDesigner and found it quite VA-Smalltalk-Like nice. After a while I was wondering if I could also connect my model to this. So is it possible to somehow introduce my model object into the Window/GUI and let QTDesigner connect signals and slots from the model object to the GUI. In essence: Write for me: connect( model, SIGNAL(fileNameChanged(QString)), ui->labelFn, SLOT(setText(QString))) connect( ui-textEdit2, SIGNAL(textChanged(QString)), model, SLOT(setFileName(QString))) Thanks for explaining

    Read the article

  • When to release the model(representedObject) of the corresponding UIViewController.

    - by user313786
    Hi, In AppKit we have "representedObject" available through NSViewController, this representedObject is generally set to ModelController or the model which the NSViewController displays, this works great with bindings as you just set the new representedObject and model details are updated in the view, BUT in case of iPhone (UIKit, with NO Cocoa bindings available), there is no such representedObject in UIViewController so here are few things I am interested in knowing:- What is the best/recommended way of binding the model to the UIViewController?, preferably dont want to maintain lot of IBOutlets and calls setters to updated the changed model data for display in view. How/When should the related model of the UIViewController be released? When is the -[UIViewController dealloc] called, in the typical iPhone application. Am looking for architecting some classes so that the UIViewController coordinates between the view and the model, but at the same time, deallocs the model when ever not necessary. TIA.

    Read the article

  • How can I update only certain fields in a Django model form?

    - by J. Frankenstein
    I have a model form that I use to update a model. class Turtle(models.Model): name = models.CharField(max_length=50, blank=False) description = models.TextField(blank=True) class TurtleForm(forms.ModelForm): class Meta: model = Turtle Sometimes I don't need to update the entire model, but only want to update one of the fields. So when I POST the form only has information for the description. When I do that the model never saves because it thinks that the name is being blanked out while my intent is that the name not change and just be used from the model. turtle_form = TurtleForm(request.POST, instance=object) if turtle_form.is_valid(): turtle_form.save() Is there any way to make this happen? Thanks!

    Read the article

  • SharePoint 2010 - Client Object Model - Add attachment to ListItem

    - by Thorben
    Hi, I have a SharePoint List to which I'm adding new ListItems using the Client Object Model. Adding ListItems is not a problem and works great. Now I want to add attachments. I'm using the SaveBinaryDirect in the following manner: File.SaveBinaryDirect(clientCtx, url.AbsolutePath + "/Attachments/31/" + fileName, inputStream, true); It works without any problem as long as the item that I'm trying to add the attachment to, already has an attachment that was added through the SharePoint site and not using the Client Object Model. When I try to add an attachment to a item that doesnt have any attachments yet, I get the following errors (both happen but not with the same files - but those two messages appear consistently): The remote server returned an error: (409) Conflict The remote server returned an error: (404) Not Found I figured that maybe I need to create the attachment folder first for this item. When I try the following code: clientCtx.Load(ticketList.RootFolder.Folders); clientCtx.ExecuteQuery(); clientCtx.Load(ticketList.RootFolder.Folders[1]); // 1 -> Attachment folder clientCtx.Load(ticketList.RootFolder.Folders[1].Folders); clientCtx.ExecuteQuery(); Folder folder = ticketList.RootFolder.Folders[1].Folders.Add("33"); clientCtx.ExecuteQuery(); I receive an error message saying: Cannot create folder "Lists/Ticket System/Attachment/33" I have full administrator rights for the SharePoint site/list. Any ideas what I could be doing wrong? Thanks, Thorben

    Read the article

  • sort django queryset by latest instance of a subset of related model

    - by rsp
    I have an Order model and order_event model. Each order_event has a foreignkey to order. so from an order instance i can get: myorder.order_event_set. I want to get a list of all orders but i want them to be sorted by the date of the last event. A statement like this works to sort by the latest event date: queryset = Order.objects.all().annotate(latest_event_date=Max('order_event__event_datetime')).order_by('latest_event_date') However, what I really need is a list of all orders sorted by latest date of A SUBSET OF EVENTS. For example my events are categorized into "scheduling", "processing", etc. So I should be able to get a list of all orders sorted by the latest scheduling event. This django doc (https://docs.djangoproject.com/en/dev/topics/db/aggregation/#filter-and-exclude) shows how I can get the latest schedule event using a filter but this excludes orders without a scheduling event. I thought I could combine the filtered queryset with a queryset that includes back those orders that are missing a scheduling event...but I'm not quite sure how to do this. I saw answers related to using python list but it would be much more useful to have a proper django queryset (ie for a view with pagination, etc.)

    Read the article

  • Entity Framework 4 "Generate Database from Model" to SQLEXPRESS mdf results in "Could not locate ent

    - by InfinitiesLoop
    I'm using Visual Studio 2010 RTM. I want to do model-first, so I started a new MVC app and added a new blank edmx. Created a few entities. No problem. Then I "Generate Database from Model", and allow the dialog to create a new database for me, which it does successfully as 'mydatabase.mdf' in the app's App_Data directory. Then I open the generated sql file (in Visual Studio). To run it of course I have to give it a connection. I am not sure if it's right, but I used '.\SQLEXPRESS' and Windows authentication. No idea how I'd tell it where the MDF is. Then the problem -- upon executing it, I get: Msg 911, Level 16, State 1, Line 1 Could not locate entry in sysdatabases for database 'mydatabase'. No entry found with that name. Make sure that the name is entered correctly. And indeed there were no tables created in the MDF. So... what am I doing wrong, or am I off my rocker expecting this to work? :)

    Read the article

  • Asp.Net MVC EditorTemplate Model is lost after Post

    - by Farrell
    I have a controller with two simple Methods: UserController Methods: [AcceptVerbs(HttpVerbs.Get)] public ActionResult Details(string id) { User user = UserRepo.UserByID(id); return View(user); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Details(User user) { return View(user); } Then there is one simple view for displaying the details: <% using (Html.BeginForm("Details", "User", FormMethod.Post)) {%> <fieldset> <legend>Userinfo</legend> <%= Html.EditorFor(m => m.Name, "LabelTextBoxValidation")%> <%= Html.EditorFor(m => m.Email, "LabelTextBoxValidation")%> <%= Html.EditorFor(m => m.Telephone, "LabelTextBoxValidation")%> </fieldset> <input type="submit" id="btnChange" value="Change" /> <% } %> As you can see, I use an editor template "LabelTextBoxValidation": <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %> <%= Html.Label("") %> <%= Html.TextBox(Model,Model)%> <%= Html.ValidationMessage("")%> Showing user information is no problem. The view renders perfectly user details. When I submit the form, the object user is lost. I debugged on the row "return View(User);" in the Post Details method, the user object is filled with nullable values. If I dont use the editor template, the user object is filled with correct data. So there has to be something wrong with the editor template, but can't figure out what it is. Suggestions?

    Read the article

  • ASP.NET MVC model binding with nested child models and PartialViews

    - by MartinHN
    I have a model called Page, which has a property called Content of type EditableContent. EditableContent have SidebarLeft and SidebarRight (type TemplateSection). I want to edit the Page instance, in my Edit.aspx view. Because EditableContent is also attached to other models, I have a PartialView called ContentEditor.ascx that is strongly typed and takes an instance of EditableContent and renders it. The rendering part all works fine, but when I post - everything inside my ContentEditor is not binded - which means that Page.Content is null. On the PartialView, I use the strongly typed Html Helpers to do this: <%= Html.HiddenFor(m => m.TemplateId) %> And so on. But because the input elements on the form, rendered by ContentEditor.ascx, does not get the "Content" prefix to its id attribute - the values are not binded to Page. So to overcome this, I've definitely done the wrong thing. Used loosely typed Html Helpers instead: <%= Html.Hidden("Content.TemplateId", Model.TemplateId) %> And when I'm dealing with a property that is a List of something it gets very ugly. I then have to render collection indexes manually... doh What am I missing here? A BindPrefix in the controller action that the Form is being posted to? Should I put both Page and EditableContent as parameters to the controller action: public ActionResult Edit(Page page, EditableContent content) { ... } Any help is much appreciated!

    Read the article

  • asp.net mvc custom model binder

    - by mike
    pleas help guys, my custom model binder which has been working perfectly has starting giving me errors details below An item with the same key has already been added. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: An item with the same key has already been added. Source Error: Line 31: { Line 32: string key = bindingContext.ModelName; Line 33: var doc = base.BindModel(controllerContext, bindingContext) as Document; Line 34: Line 35: // DoBasicValidation(bindingContext, doc); Source File: C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs Line: 33 Stack Trace: [ArgumentException: An item with the same key has already been added.] System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +51 System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) +7462172 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +270 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, IEqualityComparer1 comparer) +102 System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() +157 System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +158 System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +90 System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +50 System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1048 System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +280 PitchPortal.Web.Binders.documentModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) in C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs:33 System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +257 System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +109 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314 System.Web.Mvc.Controller.ExecuteCore() +105 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.<c_DisplayClass8.b_4() +34 System.Web.Mvc.Async.<c_DisplayClass1.b_0() +21 System.Web.Mvc.Async.<c_DisplayClass81.b_7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult1.End() +59 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8677678 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 any ideas guys? Thanks

    Read the article

  • Asp.Net MVC 2 - Iterate Through Form Values In Model Binder

    - by Noob
    I have a list of items in my form which are named like this... <input type="text" id="ListItem1"> <input type="text" id="ListItem2"> <input type="text" id="ListItem3"> I want to create a custom model binder which converts these in to model with this structure... public class MyModel { public IEnumerable<MyModelItem> Items {get; set;} } public class MyModelItem { public int Id { get; set; } public string Value { get; set; } } So each ListItem should be converted to a MyModelItem with id equal to the number at the end of the input id and value set to the value on the input field. In ASP.Net MVC 1.0 I could iterate over the bindingContext.ValueProvider.Keys collection and check for key.StartsWith("ListItem") to find all input items in this format. The new IValueProvider interface in ASP.Net MVC 2 does not have a keys collection and I cannot iterate over that interface. How can I access these values which I only know the prefix for at design time in ASP.Net MVC 2?

    Read the article

  • Symfony / Doctrine - How to filter form field by property in related model

    - by Dan
    I have a UserForm class which has a select list populated from a related model (specified by a foreign relationship in the yml) like so: $this->setWidget('report_id', new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Report')))); I'd like to filter the Report objects that come from this relation by one of the Report fields, "active" such that only Reports with active=1 appear in the form. I have a method, ReportTable::GetActiveReports() that performs the appropriate query and returns the filtered reports. So one option is to populate the Widget with the results of that function. Any tips on the syntax to do that? It seems to me the cleaner way is to use the UserFormFilter class to filter the reports by active=1 there. Unfortunately I couldn't find any documentation on how to use form filters (or really what they are), so maybe this is not the right solution. Is a Form Filter the appropriate tool for this job? It seems I should use the Doctrine_Record_Filter_Standard class as defined here: http://www.doctrine-project.org/api/orm/1.2/doctrine/doctrine_record_filter_standard.html But it's not clear to me the appropriate usage. Any guidance would be helpful. Thanks! Dan

    Read the article

  • Migration for creating and deleting model in South

    - by Almad
    I've created a model and created initial migration for it: db.create_table('tvguide_tvguide', ( ('id', models.AutoField(primary_key=True)), ('date', models.DateField(_('Date'), auto_now=True, db_index=True)), )) db.send_create_signal('tvguide', ['TVGuide']) models = { 'tvguide.tvguide': { 'channels': ('models.ManyToManyField', ["orm['tvguide.Channel']"], {'through': "'ChannelInTVGuide'"}), 'date': ('models.DateField', ["_('Date')"], {'auto_now': 'True', 'db_index': 'True'}), 'id': ('models.AutoField', [], {'primary_key': 'True'}) } } complete_apps = ['tvguide'] Now, I'd like to drop it: db.drop_table('tvguide_tvguide') However, I have also deleted corresponding model. South (at least 0.6.2) is however trying to access it: (venv)[almad@eva-03 project]$ ./manage.py migrate tvguide Running migrations for tvguide: - Migrating forwards to 0002_removemodels. > tvguide: 0001_initial Traceback (most recent call last): File "./manage.py", line 27, in <module> execute_from_command_line() File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 303, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 222, in execute output = self.handle(*args, **options) File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/management/commands/migrate.py", line 91, in handle skip = skip, File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/migration.py", line 581, in migrate_app result = run_forwards(mapp, [mname], fake=fake, db_dry_run=db_dry_run, verbosity=verbosity) File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/migration.py", line 388, in run_forwards verbosity = verbosity, File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/migration.py", line 287, in run_migrations orm = klass.orm File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/orm.py", line 62, in __get__ self.orm = FakeORM(*self._args) File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/orm.py", line 45, in FakeORM _orm_cache[args] = _FakeORM(*args) File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/orm.py", line 106, in __init__ self.models[name] = self.make_model(app_name, model_name, data) File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/orm.py", line 307, in make_model tuple(map(ask_for_it_by_name, bases)), File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/utils.py", line 23, in ask_for_it_by_name ask_for_it_by_name.cache[name] = _ask_for_it_by_name(name) File "/home/almad/projects/mypage-all/lib/python2.6/site-packages/south/utils.py", line 17, in _ask_for_it_by_name return getattr(module, bits[-1]) AttributeError: 'module' object has no attribute 'TVGuide' Is there a way around?

    Read the article

  • asp.net mvc custom model binder

    - by mike
    pleas help guys, my custom model binder which has been working perfectly has starting giving me errors details below An item with the same key has already been added. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: An item with the same key has already been added. Source Error: Line 31: { Line 32: string key = bindingContext.ModelName; Line 33: var doc = base.BindModel(controllerContext, bindingContext) as Document; Line 34: Line 35: // DoBasicValidation(bindingContext, doc); Source File: C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs Line: 33 Stack Trace: [ArgumentException: An item with the same key has already been added.] System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +51 System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) +7462172 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +270 System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, IEqualityComparer1 comparer) +102 System.Web.Mvc.ModelBindingContext.get_PropertyMetadata() +157 System.Web.Mvc.DefaultModelBinder.BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) +158 System.Web.Mvc.DefaultModelBinder.BindProperties(ControllerContext controllerContext, ModelBindingContext bindingContext) +90 System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Object model) +50 System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +1048 System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +280 PitchPortal.Web.Binders.documentModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) in C:\Users\Bich Vu\Documents\Visual Studio 2008\Projects\PitchPortal\PitchPortal.Web\Binders\DocumentModelBinder.cs:33 System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +257 System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +109 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +314 System.Web.Mvc.Controller.ExecuteCore() +105 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +39 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7 System.Web.Mvc.<c_DisplayClass8.b_4() +34 System.Web.Mvc.Async.<c_DisplayClass1.b_0() +21 System.Web.Mvc.Async.<c__DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) +12 System.Web.Mvc.Async.WrappedAsyncResult1.End() +59 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8677678 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 any ideas guys? Thanks

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >