Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










MVC :: Fill And Post List Of Objects?


I am having trouble on posting information from a View back to the controler.The thing is, I need a object "Jornada" that contains 8 "Jogos", and need to edit them all at the same time on a view. So what I did was building a class that has a List of 8 "Jogos".Everything works fine, the view renders the table correctly and I am able to insert data on the fields, but when the data is submitted, the class object "jornadaFormViewModel" that gets to the Create POST method has the list of 8 "Jogos", but all the fields are all empty.

Here is the class:

[Code]....

Here is the Constructor logic:

[Code]....

Here is the View:

[Code]....


View 3 Replies (Posted: Oct 11, 2009 07:29 PM)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Forms Data Controls :: Binding A Repeater To A List Of Objects That Have Child Objects?
have some Objects, lets say Employee and Role defined as below and I have defined relationships in my database that gives me a list of objects say employees and thanks to my framework each employee object also has a Role object linked via the RoleIDID, UserName, Password, Email, RoleIDRoleID, RoleNameSo in code I can do something like this

Employee emp = dataService_GetEmployeeByID(1);
string RoleName = emp.Role.RoleName;

Now here is my problemI can bind any object in a repeater and it works fine for the first level in my relationship

For instance <%# Eval("UserName") %>

But I need to be able to show the details for my child objects as well (Role) so something like this (which does not work)

<%# Eval("Role.RoleName") %>

Posted: Nov 17, 2010 05:03 AM

View 2 Replies!   View Related
Forms Data Controls :: Binding An Objects(containing Sub Objects) To A Dropdown List?
I know how to bind a simple objects to a dropdown list. However I am having problems binding my objects which contains sub objects to the control.i.e. with simple object i just do ddl.DataValueField = "myproperty"
with my objects they contains sub objects which i want to bind. I have tried ddl.DataValueField = "sub-object.myproperty" which doesnt work.

Posted: Apr 06, 2010 11:52 AM

View 2 Replies!   View Related
MVC :: Create Two Objects On Separate Tables Using One POST?
I'm trying to achieve something very similar to a forum. Two basic tables in a database, [Thread] and [Comment] (one to many relationship).

I need to create a form using MVC that creates the initial Thread, and also the very first comment row in the [Comment] table, which references that topic.

Would I need to create a custom object for the View Model? Is there any examples anybody knows of that demonstrate what i'm trying to achieve as I can't seem to find information..

Posted: Jan 13, 2010 04:32 AM

View 9 Replies!   View Related
Fill Dropdown List By Querystring?
I had drop down list and I want to fill it with data by specific condition i used this code but it was,t worked well

[Code]....

Posted: Apr 15 10 at 13:28

View 1 Replies!   View Related
C# - How To Fill Drop Down List From Database
How do i fill radio button list and drop downlist from database.

Posted: Feb 3 at 11:37

View 3 Replies!   View Related
C# - Fill Listbox From A List Without Any Loop?
I have one Listbox and a List of data

I want to bind the list to listbox.

Posted: Sep 30 10 at 8:30

View 2 Replies!   View Related
Web Forms :: How To Fill Drop Down List With XmlHttpRequest
I have a Question that i have.. i have2 DropDownLists the first one is cities which is filled on PageLoad the second is streets which is filled by clicking the first dropdown. I want to do this using XmlHttpRequest OR JQUERY, I always have in mind to do this using JS which calls a ASPX page and it returns the innerHTML but it seems not working. I ALWAYS get back ALL innerHTML of the whole page?!?!? this is my code that calles to a dadicated ajaxpage that returns innerhtml this is the call

<
asp:DropDownList
onchange="javascript:AjaxCall(this.value);"
ID="DropCity"
DataValueField="CityId"
DataTextField="CityName"
Width="200px"
runat="server">
</asp:DropDownList>
<asp:DropDownList
ID="DropStreets"
DataValueField="Id"
DataTextField="StreetName"
Width="200px"
runat="server">
</asp:DropDownList>
<
function
{
{
xmlhttp =
}
{
{
xmlhttp =
}
{
xmlhttp =
}
}
{
xmlhttp =
}
xmlhttp.open(
xmlhttp.onreadystatechange=
{
{
document.getElementById(
}
}
xmlhttp.send(
}
script
type="text/javascript">
AjaxCall(par)var path="AjaxPage.aspx?par="+par;var
xmlhttp=false;
try
new ActiveXObject("Msxml2.XMLHTTP");
catch (e)
try
new ActiveXObject("Microsoft.XMLHTTP");
catch (E)
false;
if (!xmlhttp &&
typeof XMLHttpRequest!='undefined')
new XMLHttpRequest();
"GET",path,true);function()if(xmlhttp.readyState
== 4 && xmlhttp.status == 200) "<%=DropStreets.ClientID %>").innerHTML=xmlhttp.responseText;null);
</
script>

I want to know how can i call a function that will talk to DB and return me a DataTable that i will populate to dropDown or any control. the problem is that a static function will not notice the control.

Posted: Oct 02, 2009 02:35 PM

View 3 Replies!   View Related
How To Add Two Objects In The Same List
Currently i am having a list like List<Tickets> allTickets.I need to select in the same list some corresponding info about the ticket writer like List<Ticket, aspnet_User>.

Posted: Feb 24, 2010 12:01 PM

View 4 Replies!   View Related
Data Won't Populate Gridview, But Will Fill Drop Down List
I'm having problems populating a gridview. I thought I did everything I needed to do, but it just doesn't fill. To see that I was infact returning data, I tried binding a dropdown list to the same datasource, and it fills the drop down list just fine. What am I forgetting?

<asp:GridView
ID="gvJointRepresentationLetters"
runat="server" [code]...

Posted: Nov 25, 2008 06:40 PM

View 5 Replies!   View Related
Web Forms :: Simply Fill A Dropdown List From A Database?
I wish tofill a dropdown list with data from a database table.

The table has ID column and a Text column.

I want the dropdown to display the Text column and return thecorresponding ID.

What control do I use? What methods can I use to retrieve the data and fill the dropdown.

Posted: Apr 14, 2010 05:32 PM

View 1 Replies!   View Related
Forms Data Controls :: HOw To Fill A GridView With A List
I have a Gridand it is filled with a list of objects... the problem is that in one column i want to show the name of one of his proporties... the problem is that this property is other object... I mean, my object medication has inside other object called producer.. so i want to show the name of this producer..

[Code]....

on the column Producer the thing that appears is : Entities.Producer.... but i want to show the name.. I tried with Producer.Name but in this way i have a error.

Posted: Dec 16, 2010 08:36 AM

View 3 Replies!   View Related
Copy List Of Objects?
I have a list of objects (List1)and I am trying to make a copy of this list (List2)and then change one of the fields in the new list.I used :

List<MyObj> List2 = new List<MyObj>();
List2.AddRange(List1);
I alos tried:
List<MyObj> List2 = new List<MyObj>(List1);
But regardless of the method,when I do:
foreach (MyObj o in List2)
o.some_field = 2

it not only changes the field in Lis2 but alos in List1. Not sure what I am missing here.

Posted: Jun 21, 2010 06:47 PM

View 3 Replies!   View Related
JQuery :: Paging Through A List Of Objects?
I have a list of objects and I would like to create my own custom control that pages through the list using Jquery to make the Ajax calls to my pager methods. I've had some experience with Jquery but need a helping hand and I really don't want to use update panels etc. So the scenario is.....user clicks next, the C# method is called using Ajax, the code gets the relevant data and sends re-populates the UI with the next item in the list.

Posted: Dec 20, 2010 09:41 AM

View 2 Replies!   View Related
C# - How To Store A List Of Objects In Session
i want to store a list of objects in session

List<ContentQueueLog> inactiveContent = GetInActiveContent(this.userID, this.visitorID);

when i store this list in sesssion it is stored but while trhying to get its null.

Posted: Jun 24 10 at 6:03

View 1 Replies!   View Related
How To Make A List Of Json Objects
I'm using asp.net mvc2 and trying to send a list of json objects with hard coded values from the home controller, and receive them in index.... in the code below i'm sending 1 json object. how do i send many?

in home controller:

[Code]....

Posted: Mar 17 10 at 12:30

View 1 Replies!   View Related
Caching - How To Cache A List Of Objects
I have a List of objects in an asp.net page. when the page loads in the browser for the first time, I fetch data from the database, create objects with those data and populate the list. All these are done inside the page load event handler. Now when the page is posted back to the page, the previous list is gone, since the variables were all freed.

How can I cache that List, so that when this page is posted back, all my objects are available?

Posted: Jan 23 10 at 20:48

View 5 Replies!   View Related
MVC :: Posting A Form With List Of Objects?
Action method takes as id parameter and returns 2 lists (eg. List<object1> and List<object2>) of objects back to the view. In order to achieve this, the viewmodel is created as below;

ViewModel
{
Int id;

[code]...

Posted: Mar 10, 2011 07:08 AM

View 3 Replies!   View Related
MVC :: Using RenderPartial To Display A List Of Objects?
I am making my first attempt at using RenderPartial to display a list of objects, but so far having little success. Here is my code, can somebody give me some guidance on what I am doing wrong?

[Code]....

Posted: Mar 12, 2011 08:14 PM

View 3 Replies!   View Related
Objects In The List With Different Variables Without Instantiate?
i have a class file in which there are some variable and there getter and setter properties

[code]...
now what i want is that i should not instantiate any object in the for loop but still have three objects in the list with different variables.

Posted: Jun 19, 2009 07:14 PM

View 6 Replies!   View Related
MVC :: Abstracting List Views Of Different Objects?
I finding myself repeating myself and the DRY side is nagging me to find an abstraction. I have a number of differententities in an MVC3 Razor web app. They are all businessobjects and each has a number of different properties that I show to the user in a list. So I have Index views and List partial views for each of these different entities (there are at least 10). I would like to abstract the List partial view so that it's capable of displaying a list of any type of entity. It simply shows them in a table with a column for each property and a row for each entity. My current thinking is that I could receive a list of objects and then use Reflection to see what properties those objects have and use those to make columns. I really wish I could receive a generic List somehow and from my various controllers just pass in an anonymous object (new {Parameter 1=param1, Parameter 2=param2}, etc.) but then I discovered that it's not possible to pass anonymous objects around.

Posted: Dec 20, 2010 08:05 PM

View 1 Replies!   View Related
DataSource Controls :: Fill Dropdown List On The Page Load Event
I am trying to fill the data source of a drop down list on the page load event. When the page loads I see System.Data.Common.DataRecordInternal rather than what I want.

[Code]....

Posted: Oct 06, 2008 03:52 PM

View 11 Replies!   View Related
Sorting A List Of Objects By An Object's Field?
Let's say I have the following class:

[Code]....

Now let's say I have a list of these objects.

[Code]....

How can I sort this book list by the Book object's BookID property?

Posted: Mar 25, 2011 04:01 PM

View 1 Replies!   View Related
MVC :: JQuery Validation Not Being Generated For List Of Objects?
I can't seem to get any jQuery generated for the input tags that are generated off my list. I'm using data annotations. Not sure if this is supported by the framework. It works fine for my textbox called "Make". I'm using ASP.NET MVC 2 Beta.I think it's related to what I'm passing to the ValidationMessage. Can't seems to find the property inside the list. Here is my code:View:

[Code]....

Business Object:

[Code]....

View Model:

[Code]....

Controller:

[Code]....

Rendered HTML:

[Code]....

Posted: Nov 23, 2009 03:34 AM

View 3 Replies!   View Related
MVC :: Load Partial View With List Of Objects?
I'm really new to MVC (just started a few weeks ago) and new to Ajax (never looked at it before today). I need some design / technical advice concerning Ajax, MVC, loading partial views, and posting / getting from a view. What I'd like to do it load a partial view that takes in a list of objects that have been queried from my db into an details-type view. The details view already has some other content that has been handeled and loaded from information pulled from my database and setup through some actions. It is strongly types to a model.

Below is the partial view I've created thus far:

[Code]....

And here's a portion of the Details page:

[Code]....

I'm not sure what to do for the Ajax.ActionLink. I'd like for a use to be able to type into the text box on it's left and hit "Add" (the Ajax link) and have the application add the content in the text box to the database. Should it be something else? An <input>? The Controller code piece is below:

[Code]....

So it should be adding the member into the repo / db and then reload the contents of the partialview. Instead, it's reloading the whole page and not just the partial view. (the url is changing from /project/details/5 to /project/membersection/).

Posted: Jul 08, 2010 12:26 AM

View 10 Replies!   View Related
ADO.NET :: Creating Dataset Using List Of Objects In Linq?
I am using Linq To Sql to get List of objects with data from database. To bind data with a grid view i am creating a dataset explicitly and then adding List values to that explicitly created dataset.

Now my question is whether it is a good pratice to do what i am doing (in terms of resource utilization) or is there any better way to this...

Posted: Oct 27, 2010 04:38 AM

View 6 Replies!   View Related
Populate A Generic List Of Objects In C# From SQL Database?
I am just learning ASP.NET c# and trying to incorporate best practices into my applications. Everything that I read says to layer my applications into DAL, BLL, UI, etc based on separation of concerns. Instead of passing datatables around, I am thinking about using custom objects so that I am loosely coupled to my data layer and can take advantage of intellisense in VS. I assume these objects would be considered DTOs?

First, where do these objects reside in my layers? BLL, DAL, other?

Second, when populating from SQL, should I loop through a data reader to populate the list or first fill a data table, then loop through the table to populate the list? I know you should close the database connection as soon as possible, but it seems like even more overhead to populate the data table and then loop through that for the list.

Third, everything I see these days says use Linq2SQL. I am planning to learn Linq2SQL, but at this time I am working with a legacy database that doesn't have foreign keys setup and I do not have the ability to fix it atm. Also, I want to learn more about c# before I start getting into ORM solutions like nHibernate. At the same time I don't want to type out all the connection and SQL plumbing for every query. Is it ok to use the Enterprise DAAB for now?

Posted: Mar 16 10 at 18:29

View 2 Replies!   View Related
MVC :: Restore List Of Custom Objects On Postback?
I have a modelcontaining aList with custom objects, let's say Customer objects. Like this:

[Code]....

In the ViewI print out (for simplicity)the name and id of the customer objects on the model. How to restore these values on postback if the method signature looks like this:

[Code]....

Should I use hidden values? This is not possible if the List contains items of interface type,for exampleList<ICustomer>where ICustomer is an interface. Is there any other way to "save" the values on each postback? For example I may want toview validation error messages when the user submits the form and then theproperties of thecustomer object must stillbe there..

Posted: Oct 21, 2010 06:49 PM

View 5 Replies!   View Related
Web Forms :: Formview - Insert Item Template - Fill Various Textfields According To Dropdown List
I have a web form for handling invoices which has a form view. When I'm in insert item template, I need to have various fields.Some of them are contract number, invoice number, register date and other that are easy to handle. But there is a dropdown list related with a table of prices (the table has price name, price initial payment, number of payments, amount of month fee and so on).So, when the dropdown is selected, fields related with price shouldget their values from price table, and then the user decides to keep them or type in new values.How can I get it done?Should I use a Dynamic populate extender or type all the code behind using SelectedIndexChanged method to populate price related controls?

Posted: Mar 26, 2010 04:06 AM

View 2 Replies!   View Related
C# - Paging Through A List Of Objects And Repopulating Using JQuery AJAX
I have a list of objects and I would like to create my own custom control that pages through the list using Jquery to make the Ajax calls to my pager methods. I've had some experience with Jquery but need a helping hand and I really don't want to use update panels etc. So the scenario is.....user clicks next, the C# method is called using Ajax, the code gets the relevant data and sends re-populates the UI with the next item in the list.

Posted: Dec 20 10 at 10:44

View 1 Replies!   View Related
Forms Data Controls :: Gridview With List Of Objects?
I have a List of Customers. Now I want to display these customers in a gridview and that is easy. I just set the datasource and use the databind method of the gridview. (I use template fields). But now I want to display FirstName and LastName of the customer as one column.I am aware of how to use the rowdatabound event to manipulate the gridviewrow's controls, but I am not sure how to gain access to the customer object within this method.So here is some code which of course not works.

protected void grdVirtualCustomers_RowDataBound(object sender, GridViewRowEventArgs e)
{
System.Web.UI.WebControls.GridViewRow row = e.Row;

((Label) row.FindControl("lblName").).Text=Customer.FirstName + " " Customer.LastName;
}

Posted: Feb 05, 2010 12:23 PM

View 2 Replies!   View Related
MVC :: Passing A List Of Entity Objects To View From Controller?
I need to pass a list of Entity Objects from Controller to View but not put it in the Model context. It is the users homepage, but I am putting a list of alerts on the users home page(somewhat like facebook). So I need the User Context as the Model I pass but need to pass the Alert model as well so I can show the list of alerts.. How would I do that? The code below is what I have so far..

UserController

[Code]....

UserRepository

[Code]....

Posted: Aug 05, 2010 01:04 AM

View 1 Replies!   View Related
C# - How To Dynamically Build A List Of Objects In A Create View
I have an Employee model that has a Name and Company

I want to be able to build multiple Employees in one CREATE view. I figured I need to create an IList<Employee> and do something like:

<%= Html.TextBoxFor(m => m[0].Name) %>
<%= Html.TextBoxFor(m => m[0].Company) %>
<%= Html.TextBoxFor(m => m[1].Name) %>
<%= Html.TextBoxFor(m => m[1].Company) %>

If a user clicks on "Add another employee", I want the view to make another form for the new employee:

<%= Html.TextBoxFor(m => m[3].Name) %>
<%= Html.TextBoxFor(m => m[3].Company) %>

And continue to add form items (and increment the array index if they click on it again).

Keep in mind that I need to build the form and the list dynamically in the create view. I don't already have a populated list of Employees.

Posted: Jul 9 10 at 4:08

View 1 Replies!   View Related
Binding Arraylist Of Class Objects With Dropdown List?
I am a beginner to ASP.Net with VB.NET and have a small question I have a class named product and an arraylist

[Code]....

I created a new object of the class

[Code]....

I have a drop down list which I want to bind with the arraylist so that it displays the product Name as a drop down optionI tried to achieve this as follows

[Code]....

but it gave me an exception that Name is not Product' does not contain a property with the name 'Name'.

Posted: Apr 29, 2009 10:41 AM

View 4 Replies!   View Related
State Management :: Best Practise For Caching Objects For A List Of?
I've created a blog for my first asp.net website. Ive got a blog class as my object. Ive created a number of methods to access my blog articles using LINQ to SQL.

Each method returns a list of objects ready to be used inthe appropriate web user control.

In my head i need to cache these lists of objects that are returned, but need to know the best way of approaching this. So i have come up with two possible options

1: Make one method to retrieve all blogs in a list<Blog> and cache this list to be used for all other methods or

2: Cache only the required methods that really need it.

Posted: Dec 07, 2010 02:46 PM

View 3 Replies!   View Related
AJAX :: Deserializing JSON Object With List Objects?
I'm having trouble deserializing the following object in a .net 3.5 webservice.The webservice looks like this:

[Code]....

[Code]....

[Code]....

[Code]....

[Code]....

Posted: Oct 27, 2009 11:03 PM

View 5 Replies!   View Related
ADO.NET :: LINQ - Exclude From A List Objects That Not Satisfying A Condition
I'm new on LINQ and I'm searching the best way to do this:

I have an object client that has a list of subscriptions. Subcription has a boolean attribute "Active". Now I want load only the clients with list > 0 and subscription active.

The question is: If a client has 3 subscriptions, but only 2 are active, how can I load only the latters ? I tried in this way:

[Code]....

The query selects clients that has at least one subscription active, but viewing the results, it loads also subscriptions not active of the same client.

Posted: Feb 16, 2011 01:29 PM

View 4 Replies!   View Related
MVC :: Passing A List Of Objects From View To Controller Via Jquery Ajax?
I have a form that I don't want to post back so I need to get the form values into my controller via jquery's ajax method.Here is my test controller method:

[Code]....

When I debug the controller method and look at the lineItems parameter, it always contains 0 items. I've tried various formats for the javascipt lineItems parameter but still 0 items. I'm also open to some other way of getting these values in like the jquery form serialze method or something else.

Posted: Jan 22, 2010 07:37 PM

View 2 Replies!   View Related
Forms Data Controls :: Display List Of Objects In GridView?
I'm creating in my code a list of object which must be displayed later in a table.

In Winforms I'd simply bind the DataGridView to the list, and everything is fine.

However, when I try to set the GridView's data source to the list, nothing happens, and I can't find a way to do this with any of the procided data sources(Such as ObjectDataSource, etc.).

Posted: Feb 16, 2010 08:53 PM

View 2 Replies!   View Related
C# - Searching In Side An Object's List Of Objects Using Lambda Expressions?
I have 2 tables; they have a many-to-many relationship. One is called Blog the other is Tag.

A Blog can contain a List of Tag objects. How can I go about getting all blogs that have a passed in tag name using lambda expressions?

Posted: Jan 28 10 at 1:19

View 1 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved