MVC :: Create A List Of Values & How To Represent A One To Many Relation?
Dec 21, 2010
i am working on a social networking project using MVC2 visual studio, currently i am working on these two tables , post & comment. Each post can have many comments.i have created a post controller along with the related view , and it work well , now i want to add under the post a comment view, where a post can have many comments , i can add the comments on different view , but i need to have a post and under it to add many comments, so how i can do so?
another problem is that in the post table there is a field representing a rating, now i can add in the rating field 1, 2,3,4,5,etc, but i need this field to be viewed as a list having values from 1-5?
View 8 Replies
Similar Messages:
Jun 20, 2010
how to create C# classes to represent one to many relationships in C#. I have a Customer and an Address table in my database. I also have a Customer class in my C# solution but how do I introduce the multiple address element? Do I have a separate Address class? Do I create a subclass in the Customer class or create a method in Customer called GetAddresses of type List which contains all of the relevant logic? In my code I need to be able to return a customer with all associated addresses and I just cannot picture the best way to achieve this using OOP.
View 9 Replies
Jan 28, 2011
Just for an example, if I have three controls on a Master page, I would usually declare a variable for a control like this.
var elem = document.getElemntId('<%=control1.ClientID %>');
var elem2 = document.getElemntId('<%=control2.ClientID %>');
var elem3 = document.getElemntId('<%=control3.ClientID %>');
Can I do it in some form of concenation like:
[code]....
View 3 Replies
Sep 7, 2010
I have the following database, consisting of 3 tables: Job, JobPhase, Assigned (as seen in the following image)
[URL=http://img836.imageshack.us/i/87157705.jpg/][IMG]http://img836.imageshack.us/img836/8710/87157705.th.jpg[/IMG][/URL]
I'm trying to create a page that will hold a table. The table will represent, for a particular employee (ID = D_ID), his/her corresponding Job Schedule sheet.
View 1 Replies
Mar 3, 2010
How do I create an array of values from a drop down list?
View 2 Replies
May 4, 2010
How can I create a comma separated string of selected checkbox values if my checkbox is of type IEnumerable?
View 5 Replies
Mar 6, 2010
I,am trying to create a self association relation for an organization chart data tree in Entity Framework,after trying different ways for prevention of exceptions like 3007 and etc. I found that when I put my foreign key in my POCO near Parent and Items navigation properties its work.but I think this is not correct that we have both ParentID scalar property and Parent navigation property. review this and tell me is it correct or not.I'm using VS 2010 RC and ofcource .net framework 4.0 RC
[Code]....
View 2 Replies
Feb 10, 2010
I have a table that has 3 fields (Individual-Id, LastName, and FirstName). I want to create a drop down table that displays both the FirstName and the LastName (example: Smith, John). The field Individual-Id is the 'value' field.
View 4 Replies
Feb 5, 2010
Is it possible to select values from a List, where the items contain in a different list aswell?for example;
[Code]....
What I need are all the items from the first list "Items", where the string contains something from the second list "List".So I need something which returns the first 3 items (which contain the term "Item") from the first list.
View 3 Replies
Aug 24, 2010
I have Check Box list in Asp.Net, contains week days like as (Monday to Sunday)
I want to store the checked values as 1, non checked values as 0, as Binary format.
Say for example: 0000011 (Monday ,Tuesday selected)
[code]
View 1 Replies
Oct 21, 2010
1 My DataTable Return following Data
Acct Books Annual
Acct Books Monthly
Acct Tax Income Tax
Admin GH Eqpt
Admin Offc Eqpt
Admin Offc Misc
Admin Offc Eqpt
[code]...
View 10 Replies
Mar 11, 2011
I have a SQL query I'm running in an ASP.NET page. The final parsed SQL needs to contain a list of string values in the WHERE [columnname] IN [values] format. For example, the final query might look something like this:
SELECT PRODUCTNAME FROM PRODUCT WHERE PRODUCTCODE IN ('ABC','DEF','GHI','JKL', /* etc */);
However, the string values in the WHERE clause need to be dynamic. Normally I use parametrized queries to make my code convenient and safe, so conceptually I'd like to do something like this:
String[] productCodes = { "ABC", "DEF", "GHI", "JKL" };
SqlCommand cmd = "SELECT PRODUCTNAME FROM PRODUCT WHERE PRODUCTCODE IN (@ProductCodes)";
cmd.Parameters.Add("@ProductCodes", productCodes);
However, this sort of functionality doesn't appear to exist in .NET. How should I go about implementing this? I could use a foreach loop on the array and run a query with a single value as a parameter for each value, but there could potentially be a hundred or so different values in the array and it seems like querying them separately would be very inefficient.
I've read another question where someone suggested a solution for strongly-typed int parameters, but that method would make me nervous about SQL injection when used with String values, especially since the client may very well be able to influence the input values.
How would you implement this query functionality?
EDIT with DB Details:
The database is SQL Server 2005.
View 5 Replies
Mar 3, 2010
I'm a novice developer writing an ASP.NET application with VB. I'm having a little trouble getting my head around the partial class concept. If you use the partial classes as a code-behind for the presentation, how would these be represented in UML, in particular with a class diagram?
View 2 Replies
Apr 19, 2010
I'm using a text box in a template field to perform an insert with an object data source. What exactly does the "ProductID" refer to in this example? Is it the column in the db or the business object?
[Code]...
View 2 Replies
Dec 21, 2010
If I have the following code:
TextBox txtUsername = new TextBox();
void setEnabled(string str, bool enable)
{
// use str to find the TextBox object
// str.Enabled = enable;
}
Is this kinda thing even possible? I want to be passing in 'Username' and then be prepending it with 'txt'.
View 5 Replies
May 26, 2010
i'm new with design patterns and i'm not sure if in this situation i can use a composite pattern.
The scenario is a web application for an address book : the address book cointains AddressBoookItem, generalization for Contact and ContactGroup. The last one is the composite object containing a collection of AddressBoookItem.
With these scenario i'm sure that this is a composite pattern, but what is confusing me is that a contact may belong to many contactgroup. Does this request change the situation? Till now i thought that between the Leaf object and the Composite (in the composite pattern) there was a 1-to-m relationship (a composite may contains many leaf but a leaf is contained in only one composite object). Can i still use the composite pattern ? And, the last question,
How could i represent my scenario in a relational database? One table for the entire hierarchy or two table (Contact and ContactGroup) with a m:n relationship between them ?
View 3 Replies
Mar 4, 2010
I need to design a system that will control access to certain information. The requirement from the user is to use access levels e.g.
Level 1 - Support
Level 2 - Manager
Level 3 - Senior Manager
Level 4 - Department Head
etc.
If a certain piece of information is marked as Level 1, then all roles should be able to view that piece of information. If it is marked as level 3, then only the Senior Manager and Department Head can view it, but the Manager and Support roles can't view it.
Questions
When I assign the access level to a piece of information, will I have to assign multiple roles to it in order for me to achieve this functionality? Is there a better way of doing this?
View 2 Replies
Mar 2, 2011
Currently I have a class that represents a document. This document needs to be displayed as HTML. I would like to have a method to call such as GetHTML() that would then call GetHTML() on any properties/sections of the document that needed to be rendered. I was initially thinking about using linq and XElement but am wondering if that may cause issues with certain tags in HTML. Would I better off using an HtmlTextWriter?
View 2 Replies
Mar 20, 2011
I'm having trouble, I have a component called Search that has a SearchCars method I use both in the objectdatasource control like this:
<asp:objectdatasource
selectMethod="SearchCars"
typename="Search"
my question is what type of object should I return from the SearchCars method?
the method seginature accepts a business entity object "Car"
like that
public ????? SearchCars(Car car)
View 3 Replies
May 4, 2010
How do I represent space (pressing the space bar in a filtered text box extender) as part of the valid characters?
View 1 Replies
Feb 16, 2011
I'm trying to add a product to one or more categories, but I'm going nowhere slow.
Table layout:
[Code]....
[Code]....
[Code]....
I been trying everything to add a product to a category, but without luck. I would have though this was the "right" way:
[Code]....
On my "Create" product page, the product is created but I just can't find a way to link a product to one or more categories. It just skips back to the Create page, even though I have put a Redirect in the Controller.
View 12 Replies
Nov 14, 2010
I need to get across relation table on linq quiry..
Table A
Column A.id
Column A.SomeValue
Table B (relation table)
Column A.id
Column C.id
Table C
Column C.id
Column C.SomeValue
Now i need to get a table with A.SomeValue and C.SomeValue
How do I linq it?
[Code]....
View 1 Replies
Feb 12, 2011
explain the relation between jQuery and JavaScript ? Since JavaScript is frequently used while in between jQuery code.
View 9 Replies
Dec 15, 2010
Can somebody justify this statement with example: delegates represent methods that are callable without knowledge of the target object. i am not getting how we are hiding the function name at the UI.
View 4 Replies
Sep 26, 2010
I have such entities
Then I tried to retrieve node type from Node this way - Nodes node = Entities.Nodes.First(); string nodetype = node.NodeTypes.Name; but for some reason node.NodeTypes equalls null despite fact that there is some records in NodeTypes table.
View 3 Replies