Transfer ViewModel Properties To Business Object?
Apr 22, 2010
I am using ASP.NET MVC 2.0 and I want to transfer my ViewModel properties to business object. I can do this manually or use AutoMapper or use new method available in ASP.NET MVC 2.0. My question is that does anyone know the name of the new method which allows to copy the properties from one object to another?
View 1 Replies
Similar Messages:
Jul 8, 2010
I have a simple ViewModel with 3 properties...I have some javascript going on where if a link is clicked, JQuery sets the values for 2 textfields (1 hidden) and a submit button where i process the rest of the Model on [HttpPost] - but for some reason some fields (the ones NOT set by javascript/JQuery) are coming back null - while on the page there is clearly values in them
[Code]....
And my Controller has the HttpGet and HttpPost, and a method that creates the nodes for the JQuery tree.
When you click on a node, this is when some values are set via javascript
[Code]....
View 4 Replies
Jun 17, 2010
Again, I am new to the ASP.NET world, and I come from a Windows Forms background. I'm working with an ObjectDataSource that retrieves a collection of business objects. With the collection, I am going to be binding it to a CheckBoxList and other various controls. The business object that I am using is an Employee.
To get all of the employees, I create an ObjectDataSource and set the "Select" method. I then set the DataSourceID of the CheckBoxList to be that of the ObjectDataSource. When I load the page for the first time, I see all of the employees. Now, the user goes through this page and selects all the employees they want to see information about (by checking the box next to the employee name). Finally, the user hits the button called "Display." Upon postback how do I get a list of those employees? I've tried the following solution, but I'm not sure if it's the best practice in obtaining all those employees again. Here's my solution...
In the CheckBoxList, I set the DataTextField to the Employee's name. I also set the CheckBoxList's DataValueField. This property is a little different. I set this to be a UNIQUE IDENTIFIER, which can distinguish this employee from other employees. Now, when the user hits the button "Display" I use my ObjectDataSource again and MANUALLY call ObjectDataSource.Select(). I cast the returned value as a List<Employee>. Finally, I iterate through all list items in the CheckBoxList...
[Code]....
If the item is selected, I parse through my list of employees that was returned from the bjectDataSource.Select(). I use the item.Value and compare it to each employee's "key." If the key is found, I know that the employee is selected. I put this employee in another list called EmployeesSelected.
Finally, I take EmployeesSelected (which is a List) and set my GridView's .DataSource and call .DataBind() on the GridView.
Is this the "best practice" of re-obtaining the Employees that are selected on my page, or am I making this too complicated?
View 1 Replies
Jan 9, 2011
I'm trying to get my own viewmodel after submit my form and I got the following error:
"Unable to cast object of type 'System.String[]' to type 'System.String'"
This is my code:
ViewMode:
public class SoftwarePackages
{
public string[] PermissionsList { get; set; }[code].....
View 3 Replies
Feb 17, 2010
On DBML I have two entities as Parent, Child. I am trying to assign Child class properites in a Parent.
[code]....
I am getting the following Error:
Cannot access a disposed object.
Object name: 'DataContext accessed after Dispose.'.
View 2 Replies
May 10, 2010
I've posted the same question in the Object Data Source forum. This is a link to it http://forums.asp.net/t/1554083.aspx. Maybe I should've posted here to begin with. There seemed to be some overlap so I wasn't sure which was the best on to post the question in.
I'm trying to get a better understanding of how I could've designed my app so that the Object Data Source could work with the properties of my business objects. Please read the other post to see how it's currently being done. Sorry for the link to the other page. I didn't want to post a bunch of duplicate information. I would love to get some suggestions for alternative ways of doing this.
View 1 Replies
Mar 22, 2010
I am having a trouble while trying to create an entity with a custom view modeled create form. Below is my custom view model for Category Creation form.
[code]....
When i click on save button, it doesnt bind the category for me because of i am using custom view model and strongly typed html helpers like that
<%=Html.TextBoxFor(model => Model.Category.OrderNo) %>
My html source looks like this
[code]....
How can i fix this?
View 3 Replies
Jun 15, 2010
I have written an application that basically gathers up a bunch of text and numerical data from the client PC and stores it as an object. Right now I'm implementing XML serialization so that the file can be saved.
The issue is now, how do I get this data to the server? I have a server running IIS 7 setup but I don't quite understand the ASP.net life cycle, so I'm not sure how to implement the receiving app.
View 5 Replies
May 30, 2010
I have a business object that looks like this:
[Code]....
What is the value of SomeId after I create an instance of my object? I was testing it with SomeId == 0 but it wasn't working. Then I tried null which gives me an error.
What is the right way to handle this? Am I to assign an initial value to my objects' properties in the object? If not, how do check if my object has any values assigned to its properties -- in particular, int values?
View 8 Replies
Jul 7, 2010
I just have a need where I have to select only selected attributes/fields of a very large business object. I ended up designing a DTO and a collection class for that DTO. Few questions.Is there any difference between a DTO and a dumb business object ? I filled the DTO inside the DAL and loaded it inside a DTO list and now returning to Business Logic layer but it seems its the same like dumb business objects to me (with only less attributes)
View 3 Replies
Mar 11, 2011
I'm implementing the MVP pattern within an existing asp.net webforms application and I was wondering if there is a clean way to map my form data to a data transfer object. I'm not particularly fond of implementing it this way:
MyObject obj = new MyObject()
{
bj.Name = txtName.Text,
obj.Description = txtDescription.Text,
obj.SomeOtherValue = txtOtherValue.Text
};
View 2 Replies
Mar 20, 2010
I finished NerdDinner tutorial and now I'm playing a bit with project. Index page shows all upcoming dinners:
public ActionResult Index()
{
var dinners = dinnerRepository.FindUpComingDinners().ToList();
return View(dinners);
}
In DinnerRepository class I have method FindAllDinners and I would like to add to above Index method number of all dinners, something like this:
public ActionResult Index()
{
var dinners = dinnerRepository.FindUpComingDinners().ToList();
var numberOfAllDinners = dinnerRepository.FindAllDinners().Count();
return View(dinners, numberOfAllDinners);
}
View 6 Replies
Jan 7, 2011
I create a database with more than 10 tables, how can I automatically generate business object class inside asp.net C# project?
I hope that one expert can give me steps for how to do that?
View 3 Replies
Feb 17, 2010
How do it do this. I have this at the moment
[Code]....
[Code]....
This takes a large INT and returns 4 strings from the BO structure HotelFacilities
If I set the private from string to AccommodationBO.HotelFacilities it is fine
If I set the public from string to AccommodationBO.HotelFacilities it moans because the Set section of the private property is wrong. But the set would be an INt.
All I actually want to do, is populate the BO Structure and passit to the user control using a property in the user control code behind. Is this possible ??
Dim jim As New GetAccommodationPricesBLL
View 1 Replies
Jun 22, 2010
What exactly is the e.Row.DataItem return.. MSDN says.. returns An Object that represents the underlying data object to which the GridViewRow object is bound.
Here is my DataGrid...
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="PracticeCode" HeaderText="PracticeCode"
[Code]....
Note : There could be other ways to accomplish this, but I'm looking especially why my p1 is null... and is there any way to get the Patient Object back from GridView after binding.
View 1 Replies
Oct 26, 2010
Is it possible to bind a rdlc report to a business object (.NET 4/VS 2010)In my report I have TextBoxes called Name and Email.Say I have an object Person with properties Name and Email.Can I bind the .rdlc with an object Person at runtime?
View 1 Replies
May 29, 2010
I do not know how to create a business object for inserting data into the database.
View 2 Replies
Jun 26, 2010
I am a new to ASP. Very experienced in MS Access... Logical move to ASP.
Problem:
When designing my first .aspx on PC and testing via localhost; all is well.
When move to server I get this error msg:
"The type specified in the TypeName property of ObjectDataSource 'ObjectDataSource2222' could not be found."
I have been reading for a solution for the past three days.
My reading tells me that there should be a reference somewhere in the web config file to id the business object dataset , but do not see any. No luck in surfing for a tip either.
I thought Visual Studio 2010 was a rapid app that allow one to design and test on PC and move easily to server for production. I am I expecting to much.
View 1 Replies
Feb 15, 2010
I have a profile object in session with profile information for the currently logged in user. I wand to be able to inject it into my business classes so I can do validation etc in them without having to pass it in the parameter list in every method.
I have tried something like this in my ninject module:
Profile profile = HttpContext.Current.Session["Profile"] as Profile;
Bind<Profile>().ToConstant(profile).InTransientScope();
However it blows up with null reference when I do Kernel.Get() in my aspx. The BusinessObject takes a profile via the constructor. If I hard code the profile instead of using the HttpContext then everything seems to work. Not sure if ToConstant is the way to go, I am really looking for something that will get evaluated every time a new BusinessObject is created.
UPDATE
It seems that asking for injection to happen on a page level object inline is too soon for the session collection to be available. If I move in the Kernel.Get call to Page_Load it works just fine.
View 4 Replies
Feb 17, 2010
I've created my dataset in my App_Code folder. I tested it so it works, But then when I add in my page an ObjectDataSource, it can find any object the list is empty. I looked for online some solution but I didn't find something which worked. It works when I add the code manually, but i would like to understand how come, which part I misunderstood.
[Code]....
View 6 Replies
Jun 30, 2010
I'm fairly new to .NET development so I might be missing something very simple here. I'm trying to set up a web service as a data item so that I can bind it to a control on my page. I was reading some tutorials about doing this in an earlier version which seemed very simple. All you had to do was add the web reference, create a data source and use the object type, pick the web service and enter the name of the call that would retrieve the data.
In 2008 the object data source type doesn't seem to be available anymore when creating a new item unde app_data. I get options for SQL Server, XML and XML schema. I've tried adding an existing source and picking each of the files generated for my web service reference, with no success. I suspect that I have to use one of the XML options, though at this point my web service is a simple thing that only returns some strings for prototyping purposes (I'm not the one writing the web service, just the front ends. Our other developer hasn't come up with a stub service yet). I know there must be some way to set a web service up as a business object so that you can bind it to a control like a gridview.
View 2 Replies
Aug 19, 2010
I have the following scenario,There is a master business object containing 40 fields2 separate child business objectsIf I update a child record, I have to update master's 'Last modify by' status along with 3 or more fields in masterFor this purpose, I don't want to initialize a separate Master class object (as most of the fields are unused/wasted)The 'last modify by' also gets updated if the records in master get updated themselvesCurrently I have separate business objects for master table, Child 1, Child 2 etc.
How do I control this in my business object design ? Do I break up my master object ? Say I extract last 'modify by ' into a new class, through inheritance or some other way ?Is there a way that whenever child gets updated I use a 'small' class to update Master status only and whenever the master itself gets updated I do the same.Problem is that I am having redundancy in my small class (Master class also contains 'Last Modify By ',
View 5 Replies
Feb 27, 2010
I want to call my business object class in which I have written my logic when any database status field change, what is the best way we can do, I want notification facility also.
I can do this window service. But there is any best way to acheive this like Notification and call my business object.
View 1 Replies
Apr 16, 2010
I need to generate a table from a List(Of Students). My Student class has properties for AcademicYear, TeachingSet, Surname and Forenames, is sorted in that order and also properties for ID and start date. The table should nest TeachingSets within AcademicYears and then the students within the TeachingSets, as shown in the table I've mocked up at http://www.ifslearning.ac.uk/files/student-table.jpg
Using a repeater I get
08-10 students B74394 Mzejb Bsppn
08-10 students B74395 Lbuifsjof Bvti
08-10 students C68924 Epoob Cmpblf
08-10 students D41468 Ipxbse Dbwfz
But I need to have
08-10 students
- B74394 Mzejb Bsppn
- B74395 Lbuifsjof Bvti
- C68924 Epoob Cmpblf
- D41468 Ipxbse Dbwfz
View 1 Replies
Sep 25, 2010
I wanTransfer values from one page to another using Request Object
but when i try store
textBox value into Request object like..
Request["Name"] = txtName.Text;
i get the following Error
Property or indexer 'System.Web.HttpRequest.this[string]' cannot be assigned to -- it is read only
Is Request object allows us to store values init like Session & Application Object.
View 11 Replies