MVC :: Display Single View Data From Two Tables?

Apr 26, 2010

how can I display on a single page(View) data from two tables in my db? In my project the model is *.edmx file. i have two table one with categories, and the second one with products. All I want to do is to display on home page(view) in left column all categories, and all products in right column. After clicking on category in left column, in right column there should be products form category which was clicked....

View 7 Replies


Similar Messages:

Display Data From Multiple Tables In A Single MVC View?

Nov 30, 2010

I am having a hard time solving the following with an MVC view. My goal is to display data from multiple tables in a single MVC view. The bulk of the data comes from a table called Retailers. I also have another table called RetailerCategories which stores the retailerid from the Retailers table and also a categoryid linking to a Category table. Note that there are multiple records for each retailerid in the RetailerCategories table.

In the view I want to show a list of retailers and with each retailer I want to show the list of categories applicable to them. What would be the best way to accomplish this?

View 2 Replies

Forms Data Controls :: Read Three Tables And Display Correspond Value On A Single Grid?

Oct 12, 2010

I have 3 tables in single database with different strctures,3 tables have unique column(partno or Jobno) , on web form search button input control(textbox) and grid view.I am pulling the data based on column jobno from single table on to grid view using following code

VB.Net Code

[Code]....

[Code]....

View 5 Replies

MVC :: Validating Objects Within ViewModel - Get Data From Three Tables And Display Them In 1 View

Apr 2, 2011

In my application, I need to get data from three tables and display them in 1 view. I have created a .dbml and created a ViewModel in my Models folder to deal with this. Here is my ViewModel:

[Code]....

My web application uses the Default ASP.NET Membership. So User [ u ] is of type aspnet_Users from the default Membership. This ViewModel allows all the CRUD opertation to be carried out. However on the Create and Update operations, I would LOVE some Model Validations, My question is:

1) Would the User [ u ] default validation kick into place in my ViewModel ? Cause I know by default ASP.NET Membership, has Model Validation.

2) For table SUserDetails (which I have created myself, not part of default) how do I add ViewModel validation to it for when someone does an Update or Create?

View 1 Replies

Forms Data Controls :: Using Multiple Tables Within A Single DataSet And Single SqlDataSource?

May 19, 2010

I have a stored procedure that returns 3 tables within the single recordset it returns. If I set a SqlDataSource to get data from this procedure, it works, but it only returns the first table. I want to have a GridView display the data from the 2nd or 3rd table using a SqlDataSource, but I can't figure out how to specify a particular table.

While there are some posts discussing this out there, I can't get a definitive answer about whether or not this is even possible (?). In a worst-case scenario, I can create another SP that only returns the 3rd table - but that creates a little maintenance headache that I would prefer to avoid.

View 4 Replies

SQL Server :: Retreive Data From 3 Tables In A Single Query?

Mar 28, 2011

Here I'm using three tables given below. As u can see in the below three tables, 3 columns(P_Id,PdtName,PdtImgUrl) are same. Now can any body tell me how can I retreive values of 3 columns(P_Id,PdtName,PdtImgUrl) without repeatition.

Coming_Products(C_ID,P_Id,PdtName,PdtImgUrl,PdtRetPrice,Startdate),
Live_Products(L_ID,P_Id,PdtName,PdtImgUrl,PdtRetPrice,PdtCurPrice,UName),
Ended_Products(E_ID,P_Id,PdtName,PdtImgUrl,WinPrice,SavingPrice,UName,Endeddate)

View 5 Replies

DataSource Controls :: Inserting Data Into Multiple Tables From A Single Web Form?

Jun 26, 2010

After creating a dataset, which has CRUD statements generated two or more tables, which Data Control should I use that will allow me to insert data into fields into 2 or more tables from a single web form. I'm trying to create a web form that will allow the user to input student information, such as general information, medical information, etc.

View 3 Replies

Visual Studio :: How To Insert Data Into Multiple Tables On A Single Web Form

Mar 20, 2010

I'd like to build an Asp.Net website using the .net 3.5 framework. I have a SQL Database called "Database.mdf"

View 1 Replies

Databases :: Insert / Update Data To Multiple Tables On A Single Button Click

Sep 23, 2010

I need to insert/update data to 3 or more tables on a single button click.What is best method for achieving this?I am using mysql as my DB.

View 2 Replies

Data Controls :: Adding Records To Two Database Tables In Single Form Page?

Jan 25, 2014

I a problem defining the variable @Bestilling in the codeBehind for adding the record to the database using a single form page. The database design with corresponding form are as below:

My ASPX.CS:
 
private void GridView1_BindData()
{
SqlConnection conn = new SqlConnection(connStr);
SqlDataAdapter dAd = new SqlDataAdapter("SELECT kart_DemoOrder.OrderID,

[Code]....

I get error in the method: "GridView1_AddNewRecord".

Must declare the scalar variable "@BestillingID". Is there a way to use only one Add Method and not two as I did?

View 1 Replies

MVC :: Get The Data From Join Tables In The View (Razor)?

Mar 5, 2011

I have two tables: Projects and ProjectsData and I want to execute query with join and get the result in the View.

In the Controller I have this code:

[Code]....

What I should use in the View to extract this data. I tried that:

[Code]....

but it doesn't work...

View 2 Replies

Make A SQL View Showing Data From 3 Tables Like Crosstab

Nov 18, 2010

I'm using ASP.net membership system with SQL Server 2000 database. What I want to do is create a view (or stored proc if that's better) which will return a table with the following columns:

UserName | Role1 | Role2 | Role3 | .... | Role*N*

Where the columns (besides Username) are generated to include all the ASP.net Roles in the application.I need this to be generic (i.e. when I add a new Role, I want the procedure/view to compensate and list that new Role as a new column). I want the values in the Role fields to be 1 (True) or 0 (false) if a user in in that role. I can make a table that has such columns using Dynamic SQL to create the variable number of columns, but I cannot seem to populate them.

How can I accomplish this?Tables involved are shown below:

CREATE TABLE [dbo].[aspnet_Users](
[ApplicationId] [uniqueidentifier] NOT NULL,
[UserId] [uniqueidentifier] NOT NULL, [code]....

View 1 Replies

Combine Data From Multiple Tables Into One View Model

Dec 5, 2010

I'm fairly new to all this, but have slowly been teaching myself C# and ASP.net MVC over the past year or so...I really tried to search for this, but haven't been able to find anything - it may be I'm using the wrong terminology!I'm using ASP.NET MVC2 with EF4 connected to a SQL Express db. Situation: Without getting into too much specifics, I have one table called 'Plan.' Under 'Plan' are several different categories that are related to a single Plan item [say Category A, Category B, Category C and Category D]. Each 'Category X' table has a beginDate, endDate and other details specific to that category.

I'd like to be able to create a summary page that combines all items from Category A, Category B, Category C, and Category D and sorts by beginDate - but only need a few of the columns [eg - begin/end date, name, id].

View 1 Replies

Get Data From Two Tables With Linq And Return Result Into View

Mar 5, 2011

I have two tables: Projects and ProjectsData and I want to execute query with join and get the result in the View. In the Controller I have this code:

ViewBag.projectsData = (from pd in db.ProjectsData
join p in db.Projects on pd.ProjectId equals p.ID
where pd.UserName == this.HttpContext.User.Identity.Name
orderby p.Name, p.ProjectNo
select new { ProjectData = pd, Project = p });

What I should use in the View to extract this data. I tried that:

@foreach (var item in ViewBag.projectsData)
{
@item.pd.UserName
}

but it doesn't work.

View 1 Replies

Get Data From Two Tables (join) With Linq And Return Result Into View?

Mar 4, 2011

I want to get data from Projects(which have CourseId) and related CourseName from Courses table.

I have written following code:

var projects = from n in db.Projects
join c in db.Courses on n.CourseId equals c.ID
orderby n.Name
select new { Project = n, Course = c };
return View(projects.ToList());

and I get error:

The model item passed into the dictionary is of type 'System.Collections.Generic.List1[<>f__AnonymousType22[ProjectManager.Models.Project,ProjectManager.Models.Course]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[ProjectManager.Models.Project]'.

What I need to do in Controller and in View to display this data?

View 2 Replies

MVC :: Display Data By Joining 2 Or More Tables?

Feb 10, 2010

I have prepared a web project using ASP.net MVC. I want to display data by joining 2 or more tables and on Edit performing updation in 2 or more tables.

I have 2 tables :
Employee_master(EmpID,Name,Designation)
Employee_Detail(EmpId,Address,Phone,DOB).

I am using ADO.Entity framework to create the model.I want to perform following operations.

1.Applying 1:1 association between the tables.
2.To show the information EmpID,Name,Designation,Address,Phone for all the existing records in tables on View.
3.On Selecting the Edit link want to show EmpID,Name,Designation,Address,Phone for the corresponding EmpId in EditView and then perform updation of the records in 2 tables both in Employee_master,Employee_Detail on Save.

View 5 Replies

MVC :: Select Data And Display It From Two Tables?

Mar 28, 2011

I really have no idea what i am doing here, but all I want to do is display a one to many list from two tables in the database in a view.

I have a ChartController with the following code:

public ActionResult ChartCategoryOne()
{
var chart = from e
in db.PTP_Exercise

[Code]....

Now I need a view. The view that VS2010 creates via the PTP_AthleteExerciseResult model looks like just what I need. But I get the following error:

The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery`1[PersonalTrainerPro.Models.PTP_Exercise]',
but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PersonalTrainerPro.Models.PTP_AthleteExerciseResult]'.

I'm not sure why it is passing PersonalTrainerPro.Models.PTP_Exercise, which is one of my automatically generated models derived from the database in the edmx and I have no idea how to set it up to pass IEnumerable instead of DbQuery. I actually have no idea what it means or even if I'm heading in the right direction.

View 2 Replies

SQL Server :: Display Data From 3 Tables?

Jul 19, 2010

I have 3 SQL tables where the first 3 colums are of same Data. I need to display data of the 3 tables together for the first 3 colums which are of same datatype.

View 6 Replies

MVC :: How To Create A Controller And View With Data Coming From Seprate Tables Associated With Foreign Key

Mar 8, 2011

I am using Entity Frameowrk as the ORM. I am new to MVC and trying to develop a samll module as a learning project.

Now I am stuck with an issue for which I can't seem to find out answer on web. The issue is :

I have two tables mapped as entities - Tenant_Definition and Contact

Tenant_Definition { Tenant_ID , Desc, Contact_ID}

Contact {Contact_ID, Company_Name,Company_Address,Person_Name, Person_Phone_Mobile}

My View has to present a form that shows Tenant Desc and Contact related fields. The index view works fine and shows the desired values.

But, the create view isn't working out. In the create view, i am planning to do -

1. creating a new contact entity instance and saving it in db

2. Then creating a new tenant entity instance using the new contact_id and save it to the DB.

However, the code doesn't seem to be inserting any value inside Contacts table. It inserts null value.Below is the code snippet of my Create Controller -

[HttpPost]
public ActionResult Create(FormCollection collection)
{
var newContact = new Contact();[code]....

View 6 Replies

Forms Data Controls :: Tree View Binding To Tables In Database?

Feb 16, 2011

I have three tables

tbl_Cus CatID (Int) CustID(int) CabID(int)
tbl_Cat CatID(int) CatName(varchar) CusID
tbl_Cab CatId(int) CabID(int) CabName(varchar)

I am using Tree View control for the first time.

The above tables I want to bind it to a tree view control the tree view should look some thing like this.

Cus Name1
Cat Name1
CabName1
CabName2
CatName2
CabName1
CabName2
Cus Name2
Cat Name3
CabName1
CabName2
CatName4
CabName1
CabName2

View 2 Replies

Web Forms :: Insert Value In Two Tables By Single SQL Query

Apr 11, 2012

How can I insert value in two tables by single sql query because if I'm using two sql query it gives problem me on binding data and connection. Like I have 2 table table 1, table 2 ... In table I'm only save id and name and in other table I'm saving id, time1, time2

View 1 Replies

SQL Server :: Joining Two Tables And Display Data?

Feb 23, 2011

am in problem and cant sort it out... my code is somwat lyk dis:

[Code]....

end sub

i hav joined both table..but am not able to display it in those controls.

View 10 Replies

How Can Search A Keyword From A Database(all The Tables) Using A Single Query

Oct 2, 2010

i am developing a web site in Asp.Net using Visual Studio 2008.i want to know that how can i search a keyword that will be entered by the user, i want the key word should be searched in complete database(all the tables)using a single query.I am using sql database. how can the keyword be searched using like parameter...

View 1 Replies

ADO.NET :: Update Two Tables From Single Gridview Using Stored Procedure?

Oct 12, 2010

I want to update two tables using stored procedures but my data not updating to data base

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace INV_DN
{
public partial class Form1 : Form
{
SqlConnection con;
SqlDataAdapter da1;
SqlCommand cmd;
// SqlCommandBuilder cb;
DataSet ds;
public Form1()

[Code].....

View 2 Replies

SQL Reporting :: Joined Tables - Concatenate Rows Into Single Row?

Feb 13, 2010

Im having a go at doing a report for my asp.net application. I have 2 tables, one which lists a loan we have given to a customer, and another table which lists repayments against the loans.

I want to display each loan and how much is outstanding against it. My problem is that each loan is repeated in the table for each repayment against it. So when i try to sum up the loans awarded to a customer, if they only have one loan and have made 3 repayments against it, it sums up the amount awarded against each record.

eg, if i award a customer a loan of £200, and they make 3 repayments of £50, 3 records appear in the table. The amount awarded is repeated against each repayment, and when i total a customers loan amounts, it totals 3 x £200.

I have put the details into the grouping row, where it is grouped by loan_id, displaying the toal of repayments instead of each repayment. This stops it repeating in the table, but when i total the amount awarded field it still calculates 3 x £200.

I tried calculating the total on the report item after grouping but you cannot calculate on a report item.

Is there a way to stop the table from repeating the amount awarded against each repayment? Or even a way in the SQL statement of the dataset to make it display a total of repayments rather than each repayment. Cant see how to calculate a total repaid as i would need to pass a Loan_id in as a parameter.

View 3 Replies







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