Display List Of Values In MVC Detail View?

Feb 2, 2010

I am new to web apps, MVC, and LinqToSql. I created an MVC web app using the NerdDinner tutorial as a guide. I'm now adding many-to-many relationships to it. And am just running into walls at every step. I have a multiselect list in the Edit and Create views. For the Detail and List views I would like to list the selected values.

I have 3 tables: Company, Subcontract, and a link table CompanyToSubcontract. I have code which gets the guid of my selected companies from the CompanyToSubcontract table which is used elsewhere in my code. I do not know how to display it.

Should I write another function to get the Company names from the Company table? Do I pass the list of names to the SubcontractDetail view and then somehow loop through it there?

Same questions with the SubcontractIndex view. The Index view is in table format, I'd like to have a "Company" column which has a comma separated list of the companies for each subcontract row.

[Authorize]
public ActionResult Details(string id)
{
subcontract subcontract = subcontractRepository.GetSubcontract(id);
IEnumerable<Guid> cmpny = subcontractRepository.GetSubcontractCompanies(subcontract.subcontract_id);
if (subcontract == null)
return View("NotFound");
else
{
return View("Details", subcontract);
}
}
[Authorize]
public ActionResult Index()
{
var subcontracts = subcontractRepository.FindAllSubcontracts().ToList();
return View("Index", subcontracts);
}

View 1 Replies


Similar Messages:

Forms Data Controls :: Need To Display All These Values In A Detail View?

Jul 28, 2010

I'm currently working on a project, i have got a web form and some text fields and drop down lists and radio buttons, i manage to store them in the database after the users click on the submit button. Now i need to display all these values in a detail view in a new web form page. Is it possible? How should i go about doing it or is there any other alternatives since i did not use the grid view for users to store their information.

View 1 Replies

MVC :: 3 Master / Detail View Inserts New Detail Records Instead Of Updating Existing

Feb 6, 2011

article on binding to a list and I've got that working fine on one view. But what I'm stuck when doing it off a master record. Everything seems to work except that when I look in the database the detail records previous associated with the current master have their Foriegn key to master set to Null and a new set of detail records have been inserted. I've got a really simple form for this object

[Code]....

The form collection comes back with the expected prefixes:

[Code]....

And the Controller.UpdateModel(master) binds all the properties correctly. But when I call dbContext.SaveChanges it issues the follow sql from sql profiler (psuedo code)

[Code]....

I've got a work around that works but it's pretty hackish and I'm currently not matching up the keys so it's dependent on everything coming back in the right order. Plus I've got to include all the fields that I want updated.

[Code]....

I thought that entity framework's code first was the culprite but I've unit test that and it works fine. I've got a feeling that UpdateModel is somehow removing and re-adding the children. Has anyone else got this to work? Of course, I could throw in the towel and parse the indexed field names myself, but I'm so close!

View 2 Replies

Javascript - MVC List With JQuery - Links - View To Display A List Of Products

Nov 5, 2010

I am using a strongly-typed view to display a list of products, where every li-element gets a unique id:

<ul id="product-list">
<% foreach (var item in Model.Products)
{ %>
<li <%= "id="product_" + item.Id + """ %> >
<div class="item">
<%= item.Name %>
</div>
</li>
<% } %>
</ul>

Now I want to attach to the click-event of every single li-element, so that if the user clicks on a div-element, detailed product-informationen should be loaded asynchronously into a details-pane. I know how I can use jQuery to invoke an action-method ajax-style and also how to display the json-result which contains the product-details, BUT I have no idea, how I could attach the onclick-event to every single div, so that I can use the productId to load the details.

View 4 Replies

MVC :: How To Display List Of Images In The View Using List Of URLs

Nov 10, 2010

I'm trying to display a list of images in the View. I have a list of URLs (List<string>) that I'm passing from the Controller using ViewData["imageURLs"], but nowI have no idea how to generate and display them?

View 2 Replies

MVC :: Load View And Partial View (Master / Detail) With Default Parameter?

Sep 8, 2010

Members view (index) that lists members that users can select to show a partial view in the same view with details for the selected memberUses jquery (Ajax.ActionLink) to call a partial view method in the members controller to then load the members detail sectionWorks fine up to here....but I'd like to load the partial view with "member" details for a default or random member on initial load -- ie not through the Actionlink selectionHow do I invoke the partial view method on the initial load?

View 4 Replies

MVC :: Retrieve A List Of Values From View?

Mar 15, 2010

I have two tables related to a number (ie, persons with Firefox), I should retrieve data from a View where he imposed the following code:

[Code]....

When I go to send the following to view controller via Post did not recover the data, the controller parameter dell'actin as I pass him the Person object p.Qualcuno potrebe me explain why I get the results and those of the Person objectcomponents, I do not return?

View 11 Replies

Data Controls :: How To Pass List Of Values From One To Another View In MVC Mobile App

Jan 10, 2013

I have 2 views(2 view pages) in first view page I will display some names in this page i will have add button after clicking on add button it will redirect to another page (2nd view page) in this i will display multi selected list or listview then i will select multiple items from multi selected list now this selected items has to bind with first view names and display updated list in 1st page?

My question is this selected items in 2nd view page has to bind with 1st view page and display how to do this using mvc razor for mobile application? 

View 1 Replies

C# - How To Display Selected Values From List Box In Label

May 28, 2010

I have a list box with multiple selection option , i wanted to display user the selections he has made .

How to display that users in stylish way .

View 1 Replies

C# - How To Calculate Row-wise Sum Of Values In Grid-view And Display It In Grid View

Mar 14, 2011

I have a grid view which displays some values. now i have to calculate row wise sum of those values for each row and then display against them.i tried this code but i am getting error as Input String Was not in Correct Format.

public void gv_RowCreated(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int total = Convert.ToInt32(e.Row.Cells[1].Text) + Convert.ToInt32(e.Row.Cells[2].Text) + Convert.ToInt32(e.Row.Cells[3].Text) + Convert.ToInt32(e.Row.Cells[4].Text) + Convert.ToInt32(e.Row.Cells[5].Text) + Convert.ToInt32(e.Row.Cells[6].Text) + Convert.ToInt32(e.Row.Cells[7].Text);
((Label)gv.FindControl("Label8")).Text = Convert.ToString(total);
}
}

View 2 Replies

Forms Data Controls :: Display Images In A List View?

Jan 12, 2011

I want to display images that a user uploads in a list view so that all the images a user uploads will appear as at the moment no images appear using the list view but the xml data source file gets updated. I am using VS 2008 usinf asp.net, vb and xml codes. What would I need to do so that the images appaer in the list view.

The code I have used in the aspx page is:

<asp:ListView ID="ListView3" runat="server" DataSourceID="XmlDataSource1">
<LayoutTemplate>
<div id="itemContainer">
<span id="itemPlaceholder" runat="server" visible="true" />

[Code]....

View 6 Replies

Web Forms :: Display Some Data In A List View With An Edit Button?

Apr 22, 2010

I'm attempting to display some data in a list view with an edit button beside them so I can edit them in a different form. I want to get the currently selected item but it's always -1 and the selectedndex doesn't seem to fire.

View 7 Replies

Forms Data Controls :: Reverse Display List View From Database?

Mar 1, 2011

I have a simple list view that displays some text and a picture. The text is stored in the database and new text is inserted into the database through the list view. The list view displays all of the data with the oldest, or first, line of the database first. I want to reverse that by displaying the last line, or newest entry first. The site is live, and I do not know how to change the database remotely. Can I put some code on the page or code behind that will accomplish this? What is it called and where do I look?

View 5 Replies

Forms Data Controls :: Drop Down List Values Are Lost When Cancel Is Clicked On Details View?

May 12, 2010

I have a detailsview which includes a drop down list bound to an array. However, when I click on the cancel button the dropdownlist values disappear. I have tried to solve the problem by rebinding the values back into list on the cancel command event, but this has made no difference. Does anyone know how to solve this?

View 2 Replies

MVC :: Master Detail (in The Same View)?

Aug 10, 2010

Master Detail (in the same view)

View 3 Replies

C# - How To Use Update In Detail View

Jul 28, 2010

There is button Update in detail veiw which automatically transform the column to textbox can any body tell me where to code the update code;in .aspx or in .aspxcs

View 1 Replies

Forms Data Controls :: Display Two SQL Column Values In One Dropdown List

Apr 16, 2010

Is it possible to display two column values from a SQL database in to one DDL? I have been trying to write a SQL query, where in I select two fields to be displayed in the DDL but when I run the application it only displays one. Not sure why. Here is my code below:

<asp:DropDownList ID="DropDownList8" runat="server"
DataTextField="LATA"
DataValueField="LATA"
onselectedindexchanged="DropDownList8_SelectedIndexChanged"
DataSourceID="SqlDataSource1">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%&#36; ConnectionStrings:Inventory_DBConnectionString %>"
SelectCommand="SELECT DISTINCT [LATA], [LATA Name] AS LATA_Name FROM [CA] WHERE ([SWITCH ID] = @SWITCH_ID)">
<SelectParameters>
<asp:QueryStringParameter Name="SWITCH_ID" QueryStringField="ddl1"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>

View 3 Replies

Asp ModalPopupExtender Not Displaying Detail View?

Jul 26, 2010

am using a ModalPopupExtender within an updatePanel to show a detailView when a user selects a "Details" Button within a GridView.The problem is that when the button is selected the popup is not being displayed. I have stepped through the code and the mdlPopup.Show() method is being executed but the popup does not "Show" Could someone perhaps help me out with what is happening?Here is my Code:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetRequests"
TypeName="RequestDAL" SortParameterName="SortExpression"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjectDataSourceDetails" runat="server" SelectMethod="GetRequestsDetail"

[code]...

View 1 Replies

How To Get The Column Titles From The Display(Name=) DataAnnotation For A Strongly Typed List Scaffold View At Runtime

Feb 9, 2011

how do i get the [Display(Name="Some Title")] DataAnnotations "Some Title" rendered in the List scaffold view's output?

I create a strongly typed list scaffold view for this class:

public class CompanyHoliday
{
[Key] [code]...

However i don't want "Date" and "Name" in the table header - i want "Datum" and "Feiertag Name" rendered there dynamically. The actual column header titles should come from the Display Dataannotation.

View 2 Replies

Web Forms :: Master-Detail From A DropDown List?

Aug 3, 2010

I have a master - detail query that I'm trying to run and I've run into a road block... I have a table with 'County' as one of the fields. I'd like to display the county name in the drop down list, and then display the details of that record in a 'details view/grid' below the drop down list. Here is what I have so far:

[Code]....

I'm getting the error: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1061: 'ASP.default_aspx' does not contain a definition for 'DropDownList1_SelectedIndexChanged' and no extension ethod 'DropDownList1_SelectedIndexChanged' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?)Source Error:

[Code]....

View 4 Replies

C# - Handle Page Event In The Detail View?

Aug 9, 2010

Using C#

Table

ID Name

001 Raja
002 Ramu
003 Ravi
004 Sajuee

Detail View Code:

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" Height="50px" Width="125px" AllowPaging="True" EnableViewState="False">
<Fields>
<asp:BoundField DataField="ProductName" HeaderText="Product" SortExpression="ProductName" /> <asp:BoundField DataField="vehiclename" HeaderText="Category" ReadOnly="True" SortExpression="vehiclename" /> <asp:BoundField DataField="platecode" HeaderText="Supplier" ReadOnly="True" SortExpression="platecode" /> <asp:BoundField DataField="inscom" HeaderText="Qty/Unit" SortExpression="inscom" /> <asp:BoundField DataField="inedate" HeaderText="Price" SortExpression="inedate" /> </Fields>
</asp:DetailsView>

When i run the code, Details View is Displaying First ID, First Name from the table.

Detail View Displaying like this

ID 001

Name Raja

Link: 1 2 3 4

But when i click the link2 it showing errors as "The DetailsView 'DetailsView1' fired event PageIndexChanging which wasn't handled."

Details View is not displaying all the data.

View 1 Replies

Forms Data Controls :: Create A Dropdown List That Concatenates Two Values In The Display Field?

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

Forms Data Controls :: Update Detail View In Vb.net?

Jan 18, 2010

have been through this que a long time ago, but seem no ans was found. I gonna post it again.I have a Detail view to control the detail of user, but i didn't bind it with any data source, the only i use is bind it with the sql command in vb.net code. I can open the Dv in edit mode but cannot update it with update button. I have read many post but some use data source or use store procedure. I can't use both.I do this because i wan to update multiple sql statement.

View 6 Replies

Forms Data Controls :: Updated Detail View At Code Behind?

Jan 4, 2010

I was trying to update a detail view from code behind (vb.net). I know how to fire the event but dont know where to put the DML query where i should do update and insert, i mean in which event?:

update.aspx

[Code]....
update.aspx.vb
[Code]....

No error but is not working.

View 9 Replies

Forms Data Controls :: Moving From One Field To Another In A 'Detail View' Form?

Jul 1, 2010

I am using a "Detail View" to edit the data in my "Customer" table. The fields are "CompanyName", "ContactPerson", "StreetAddress", and "City". If I type data into the first field ("CompanyName") and then press the "tab" key, control moves to the second field "ContactPerson". However, if I type data into the first field ("CompanyName") and then press the "Enter" key, instead of control moving to the second field ("ContactPerson") the program closes the form.

Is there someway that I can control the action of the "Enter" key so that this will not happen?

Also, is there any way that I can have control move from the first field ("CompanyName") to a field other than the seconc field ("ContactPerson") if the content of the "CompanyName" field contains the value "Internal"?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved