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


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

Similar Messages:

ADO.NET :: How To Write Queries To Select Data From Different Tables With Condition

Jan 23, 2011

eg: thiss is the ordinary query


how in linq??

View 1 Replies

SQL Server :: Query To Select Data From Multiple Tables And A Different Database?

Dec 1, 2010

Is there a way to select data from multiple tables other than the UNION ALL statement. Addtionally I need to select data from a different database.

My current statement is as follows (there are alot more fields but I have shortened it ):

WHERE (BSFLBWF_1.Closex IS NULL).........

View 4 Replies

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

Feb 10, 2010

I have prepared a web project using 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 :

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

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 :: 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

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:


end sub

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

View 10 Replies

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 :: Display Data From Two Tables And Post Back?

Mar 16, 2010

I have two tables. 1st contain topic and its id. 2nd contain topic name,its category and category list.

I want to display using asp .net datalist and vb script like the following

topic 1
Category 1
categorylist 1 of category 1
categorylist 2 of category 1
Category 2
categorylist 1 of category 2
categorylist 2 of category 2
topic 2
Category 1
categorylist 1 of category 1
categorylist 2 of category 1
Category 2
categorylist 1 of category 2
categorylist 2 of category 2

Also, i have tried displaying only Category 1, 2 .. which are Link button. When I click these button it shows category list. So here I am facing aproblem that everytime i click these buttons it refreshes my page which is very annoying.

View 9 Replies

Forms Data Controls :: Display 2 Tables Data In One Grid?

Jun 30, 2010

i want to display 2 tables data in gridview (,mysql) for particular ID

View 3 Replies

Data Controls :: Display Data From Two Tables Into One Gridview Through Datasource

Feb 20, 2013

i have a problem in joining two tables the reason ismy first table persdata is having common field as pno (a single row in a particular person) and the second tables is also having pno(having muti entry for a person as this table is of qualification and a person may have more than 3 qualifications and their grading)sample persdata(table)pno name coy appt sample qual(table)pno qual grading recommendationi tried my best to do it and not able to proceedi want the output in a single row as in persdata to a gridview with all the qual combined in one coloumn and all the recommendations combined in one coloumn for a person.

View 1 Replies

Data Controls :: Display Data In GridView Based On Two Tables

Nov 28, 2012

I have two tables Emp,Dept

EMP                          DEPT

EmpNo(PKEY) Id(FKEY) to Empno
Fname Location
Lname Date

I want to display Gridview columns like this ....

E.Fname,E.Lname, based on Id
Display E.Fname,E.Lnamebased ob Id

View 1 Replies

Data Controls :: Display Data From Multiple Tables Using LINQ To SQL In MVC

May 7, 2015

I have to display records from two tables where foreign key table contains many values for a primary key column how to get the data using linq query???

View 1 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:


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 :: Navigation Menu Display Using More Than One Tables

Jan 8, 2011

My issue is,i have two tables

Table Maincategory:
Category name,

Table Subcategory:

My issue is, i need to display my Table(A) categoryname in my vertical menu such as


if i click ashok, with respect to its id,(say id is (1),it should pick the subcategoryname (2nd table's) name corresponding id(1) from 2nd table...and it should display as sub menu is it possible.

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



View 5 Replies

Data Controls :: Search Multiple Tables In Database And Display Result In GridView?

Apr 5, 2014

I want make a search by which want find data and display in gridview.

View 1 Replies

SQL Server :: Select Column From All Tables In Database?

Sep 3, 2010

I want to retrieve the name and phone columns from all the tables in my database not in systables.

Ok this works but i dont want to get it from just the test table I want to get it from all the tables that I create

"USE mrpoteat SELECT name, phone FROM mrpoteat.dbo.test where name = name and phone = phone"

View 3 Replies

SQL Server :: Select Statement For Multiple Tables

Oct 1, 2010

SELECT u.Email FROM UserProfiles p, aspnet_Membership u WHERE p.RulesCheckBox = 'True' AND u.UserId = p.UserId This gives me a list of registered member email addresses that have selected the RulesCheckBox in their profile, so I can email them with an email script. There is a relationship between the Membership table and the UserProfile table, so it finds the email addresses from the Membership table where that user has the RulesCheckBox checked in their profile (in UserProfiles table). I'm wanting to add some additional names to this list, from a different table. The purpose is so I can manually add email addresses to the additional table, so the additional email addresses will also receive the same email, even though they aren't registered members of the site. So how can I adjust that SELECT statement so this one is combined with it somehow?:

SELECT Email FROM ExtraEmails WHERE Rules = 'true'

View 4 Replies

DataSource Controls :: Select Statement Across Three Tables?

Mar 17, 2010


Select statement across three tables

View 15 Replies

When Select To Display Different Data The Page Is Very Slow?

Oct 16, 2010

in the last period i am working to do my site faster i think it has been faster in many parts

the last part that i think that has problem is the page of the forum that posts are displayed

the strange is that although the first time the page is loaded fast,then when i select to display different data(i click a button that shows the data that i want to be displayed) the page is very slow

these buttons are created dynamicaly with controls.add(button) i dont know if it has to do with delay

gep another time had suggested to use trace but i didnt found how to use trace

i add trace=true in the page but nothing happens where can i see trace results??

View 19 Replies

DataSource Controls :: Count From Several Tables In One Select Statement

Mar 14, 2010

I am trying to count records belonging to a certain person in three different tables in a single select statement. The database looks like this:



-GameId (FK->Game.GameId)
-PlayerId (FK->Player.PlayerId)
-Assist (FK->Player.PlayerId)

-GameId (FK->Game.GameId)

I want to select the number of goals, assist and cards a player has in a specific tournament. I tried with this query but then the goal and card column shows the sum of the number of rows matching the playerid in the Goal table and the Card table...For example if there is two matching rows in the goal table and three matching rows in the card table, I get 5 in both these columns in the resultset.


View 3 Replies

DataSource Controls :: How To Select Multiple Tables By Using LinQ In MVC

May 19, 2010

I'm using ASP.NET MVC to create a small web apllication.

Here is my database And here is my class


View 2 Replies

Forms Data Controls :: When Select Items From Second Dependent Dropdown Does The Grid Display Data

Jun 8, 2010

Iam trying to understand why my sqldatasource control bound to gridview will not return data while i have cascading dropdownlist coded in pageload and selected events respectively?

from which sqldatasource control stored procedure obtains its parameter values.

only when i select items from second dependent dropdown does the grid display data?

View 10 Replies

SQL Server :: Display Data From Select Statement To A Label?

Oct 19, 2010

sql_select = "SELECT auid FROM tbl_auAccount WHERE username='" & IUN & "'"
'Add Error Trapping Later
con = Server.CreateObject("ADODB.Connection")
'Execute the SQL Command
'Close the connection
con = Nothing

Now this works and I was able to put the value into a dropdown list box, but I need the value returned placed into a label such as:

lblShowNewUserID.Text = ? (? being the value returned from the Query). I thought this would be simple, but it is not (at least for a newbie like me). NOTE: (I will have instructions before this to be sure that only one value will be returned and taht the value will not be null).

View 14 Replies

Copyrights 2005-15, All rights reserved