Forms Data Controls :: Gridview Update With Related Tables

Nov 24, 2010

I have a problem in getting my gridview to update. The datasource gets its data from 2 related tables using the following select statement:

SELECT StudentSubject.StudentID, Students.[1stName], Students.Surname, Students.Grade, StudentSubject.Subject, StudentSubject.GradeOverall, StudentSubject.ReportYear, StudentSubject.ReportSession, StudentSubject.Criteria1Grade, StudentSubject.Criteria2Grade,
StudentSubject.Criteria3Grade, StudentSubject.Criteria4Grade, StudentSubject.Criteria5Grade, StudentSubject.Criteria6Grade, StudentSubject.Criteria7Grade, StudentSubject.Criteria8Grade, StudentSubject.Criteria9Grade, StudentSubject.Criteria10Grade, StudentSubject.Comment
FROM (Students INNER JOIN StudentSubject ON Students.StudentID = StudentSubject.StudentID)
WHERE (StudentSubject.Subject = ?) AND (StudentSubject.ReportYear = ?) AND (Students.Grade = ?) AND (StudentSubject.ReportSession = ?)

The ? stem from combo box controls which I use to filter the results So far so good!

However, when I try to update the data in just one of the tables, nothing happens, no error, just no update. The update statement I'm using is:

UPDATE StudentSubject SET GradeOverall = ?, Criteria1Grade = ?, Criteria8Grade = ?, Criteria7Grade = ?, Criteria6Grade = ?, Criteria5Grade = ?, Criteria4Grade = ?, Criteria3Grade = ?, Criteria2Grade = ?, Criteria9Grade = ?, Criteria10Grade = ?, Comment =?
WHERE (StudentID = ?) AND (Subject = ?) AND (ReportYear = ?) AND (ReportSession = ?)

I've tried this with a similar setup with just on table and it works fine.

<asp:AccessDataSource ID="DSGrid" runat="server"
DataFile="D:RW docsVisual Studio 2008WebSitesFellbach ReportsApp_DataReports - Copy.mdb"
SelectCommand="SELECT StudentSubject.StudentID, Students.[1stName], Students.Surname, Students.Grade, StudentSubject.Subject, StudentSubject.GradeOverall, StudentSubject.ReportYear, StudentSubject.ReportSession, StudentSubject.Criteria1Grade, StudentSubject.Criteria2Grade,
StudentSubject.Criteria3Grade, StudentSubject.Criteria4Grade, StudentSubject.Criteria5Grade, StudentSubject.Criteria6Grade, StudentSubject.Criteria7Grade, StudentSubject.Criteria8Grade, StudentSubject.Criteria9Grade, StudentSubject.Criteria10Grade, StudentSubject.Comment
FROM (Students INNER JOIN StudentSubject ON Students.StudentID = StudentSubject.StudentID) WHERE (StudentSubject.Subject = ?) AND (StudentSubject.ReportYear = ?) AND (Students.Grade = ?) AND (StudentSubject.ReportSession = ?)"
UpdateCommand="UPDATE StudentSubject SET GradeOverall = ?, Criteria1Grade = ?, Criteria8Grade = ?, Criteria7Grade = ?, Criteria6Grade = ?, Criteria5Grade = ?, Criteria4Grade = ?, Criteria3Grade = ?, Criteria2Grade = ?, Criteria9Grade = ?,
Criteria10Grade = ?, Comment = ? WHERE (StudentID = ?) AND (Subject = ?) AND (ReportYear = ?) AND (ReportSession = ?)">
<SelectParameters>
<asp:ControlParameter ControlID="ComboSubject" DefaultValue="German" Name="Subject" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ComboYear" DefaultValue="2010 - 2011" Name="ReportYear" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ComboGrade" DefaultValue="1a" Name="Grade" PropertyName="SelectedValue" Type="String"/>
<asp:ControlParameter ControlID="ComboSession" DefaultValue="November" Name="ReportSession" PropertyName="SelectedValue" Type="String"/>
</SelectParameters>
</asp:AccessDataSource>
<asp:AccessDataSource ID="DSGrid" runat="server"

View 10 Replies


Similar Messages:

DataSource Controls :: Batch Update A Dataset Table Which Data Are From Related Tables?

Jun 8, 2010

My dataset table data is from multiple tables (showing on a gridview),How to update the database tables using batch udpate on clicking submit, if the data is from a signle table, no problem, but I am not sure how to handle if the datais from mulitiple tables? If I have related tables, do I need put them in differet tables in the dataset?

View 6 Replies

Forms Data Controls :: Binding Gridview To Related Tables Of A Dataset

Mar 24, 2010

i have this xml file which i read using the DataSet.ReadXml( path ) method . The tables created from the Xml file is Related in such a maner that each product has many options. Product is in one table and Options are in another.Now all i want to do is display the related tables in One Gridview. For your reference below is the products Xml file,

[Code]....

Now this is what i have done in the Code behind , have a look below

[Code]....

Now the Grid works Great if i want to Display Individual tables out from Dataset but not when they are related . Please do shine your Knowledge on what should be done to display Child ~ Master relationship. By the way , its a definite NO for someone who would show me that link from msdn about displaying XML data using Xmldatasource and gridview [That's a lousy way to display data]

View 2 Replies

ADO.NET :: Update Sql Server Related Tables From Dataset (SchemaFill)?

Aug 25, 2010

I would like to update new records that get inserted in DataSet to Sql Server Database. Below is a working example of how to do this if you use "DataAdapter.Fill(ds)".

But i don't want to fill data, becouse i don't need data, i only need shema (I will use this dataset to insert new data to Sql), so i would like to use "DataAdapter.FillSchema(ds)"

[Code]....

View 4 Replies

Columns Of Two Related Database Tables In One GridView With EntityDataSource

Feb 17, 2010

I have two SQL Server tables with Primary Keys (PK) and a Foreign Key (FK) linking the two tables:

1) Table "Order"

OrderID, int, PK
AddressID, int, FK
...

2) Table "Address"

AddressID, int, PK
City, nvarchar(50)
...

Then I've created an (ADO.NET) Entity Data Model out of those two tables. Now on my (ASP.NET) webpage I put a GridView with an EntityDataSource. In my GridView I want to display two columns:

OrderID City (belonging to that order and linked by the AddressID-key) How can I do that? My problem is: When I configure the Entity Data Source I can select an "EntitySetName" which can be either "Order" or "Address" but not both, nor can I select any kind of relationship. If I select "Order" as EntitySetName
then in the GridView I can add the columns

OrderID
Address
Address.AddressID

Adding the column "Address" displays empty cells. Adding "OrderID" and "Address.AddressID" displays the expected IDs. But how can I add the "City" of the related address to my GridView? Edit: Clarification:

The Entity Framework has created a class "Order" and a class "Address" corresponding to the database tables. The class "Order" has a reference to an "Address" object as a navigation property, corresponding to the 1-n relationship between Address and Order table. Basically I want to have a column in my GridView which displays Order.Address.City. I have tried to add a bound field with "Address.City" as data field to the GridView but it results in a runtime error ("no such property...").

View 3 Replies

Forms Data Controls :: Two Ddls On A Formview Which Are Not Related But Just Insert And Update Into Each Other?

Jul 21, 2010

Am not sure how to go about this... but i have two ddls on a formview which are not related but just insert and update into each other... Both are binded to the objectdata source....

Am issue just came up and i am looking for the simplest way on code behind that would automatically post a constant value (selecteditem) once the first ddl clicks on 1 or 2....

Example is

lst DDL Second ddl

ABC bko

DWC loct

qwe jjjj

Now when ABC is clicked... it should automatically bring out JJJ on the second ddl.... I just want something i can do on code behind.

View 12 Replies

DataSource Controls :: All The Related Records Across Tables At The Same Time?

Mar 19, 2010

Let say you read a customer record into Customer object. Do it read all the related records across tables at the same time Or it only reads when you do from o in customerobject.orders

View 2 Replies

Web Forms :: Tables In LINQ To Entities Are Not Related

Aug 3, 2010

I'm working with asp.net 3.5 WebForms and LINQ to Entities.

I created the database with their relationships, but when I go to import the data with LinqToEntities, some reports and have not seen any reports 1 to 1.

I can create them after the reports have imported the tables LinqToEntities?

View 1 Replies

Forms Data Controls :: Display Multiple Related Items In An Asp GridView?

Jun 9, 2010

I would like to display students and their grades with a GridView and LinqToSQL like this:

[Code]....

I found this topic but it doesn't answer my question: http://forums.asp.net/t/1557987.aspx

I have a many-to-many relationship between students and assignments called "grades".The grade for the assignment is stored in that table in a "gradeNumber" column.The many-to-many relationship seems to be a problem.I tried adding a TemplateField to my grid:

[Code]....

It doesn't work:
...student does not contain a property with the name grade.

It does work when I use class.name however to get a student's class he is in.In code students .grade[0].something works however My LINQ entities are extended with custom code to allow me to retrieve studentx.Assignments or assignmentx.Students.(I would also like to specify which assignments should be displayed in the grid.)

View 1 Replies

Forms Data Controls :: How To Show Data From A Related Table In A Gridview / Entitydatasource

Feb 23, 2011

I am using an ADO Entity Model for my ms-sql database.

My database has a Resellers table which has ResellerID (primary key, int) and Name columns along with other data.

I also have an Orders table which contains OrderID (primary key, int), OrderDate, ResellerID (foreign key to Resellers.ReselerID).

If I just do a query like:

[Code]....

I am able to reference order.Reseller.Name just fine with no problems.

However I have an EntityDataSource on my page as follows:

[Code]....

Notice the Include="Reseller" attribute in the datasource... I also have a GridView tied to that datasource as follows: I cut some of it off for breavity:

[Code]....

Now what I have listed above will run with no errors, but what I want to do is replace the column that displays "ResellerID" with the equivilant to order.Reseller.Name. In other words I want my grid to display the reseller's name rather than the numeric ID.

I have tried to change the DataField to "Reseller.Name" but that will generate the following error:

A field or property with the name 'Reseller.Name' was not found on the selected data source.

Is there anyway to do this without me writing a custom select statement in my code behind?

View 2 Replies

Forms Data Controls :: Update Multiple Tables From DetailsView?

Nov 29, 2010

I have a asp:DetailsView control with the first column are the field headers and the second column is the record details for a given user.

The DetailsView is bound from 4 tables, I need to be able to edit/amend any field. Is there another way I can achieve this from the DetailsView? Would I need to create templates for each table entry then Update SET on each template, would that do it?

View 8 Replies

Forms Data Controls :: How To Update Multiple Tables With A SQLDataSource

Mar 3, 2011

I have 2 tables

One:Table Name Rider With columns RiderID,LName,City

Two:Table Name Car With columns CarID,RiderID,Color

What I would like to be able to do is to allow the users to do an UPDATE on both tables.

Like if you crreated a SQLDataSource using just one table as it's source. You can use that SQLDataSource for a gridview.

Then in the gridview you can display all the data from the table but you can also EDIT all the data in the table through the gridview.

But if I create a SQLDataSource using 2 table joining them together with an INNER JOIN with a Primary Key in one table and a Foriegn Key in the other table. I can still use this SQLDataSource with a GridView to display the data but I can't EDIT the data through the gridview for the 2 tables.

Is there anyway to do this using a SQLDataSource and GridView?

OR is there another way to accomplish this?

View 3 Replies

Forms Data Controls :: Gridview Column With Data From Related Table In SQL Db?

Aug 18, 2010

I've got a gridview that is databound with LINQ in the code behind. One column shows the id from the table. I would like to show a more human friendly product name that is associated with that id number but is from another table. Thought I had it figured out by entering a Template field in the gridview tags (in the .aspx page) and an item template within that with

<ItemTemplate>
<%Eval(Products.productName")%></ItemTemplate>

but when I try to build it says this can only be done in the context of a databound control.

Can I add this column within the gridview tags or does it have to be done from the code behind?

View 3 Replies

Forms Data Controls :: How To Display Related Foreign Key Value In Gridview With Entity Framework

Oct 12, 2010

I have a gridview displaying "registrationtype id" (FK) from the registration table. I want it to display the related name instead of the id from the registartiontype table.

View 1 Replies

Forms Data Controls :: Finding Best Way To Handle This Scenario - Select Gridview Row And Show Related Info Below?

Dec 12, 2010

almost typical master-detail scenario except the 'detail' data I want to display below the gridview will be coming from both the table that is bound to the gridview (master) and a related table.

simplified example: tableMain with field1, field2, field3 bound to master gridview. I need to select a row from the master gridview and have a form display below with field4 and field5 from tableMain, as well as all fields of tableDetail where field1 of tableMain equals field1 of tableDetail.

Is this what a 'formview' control is for? or do I just arrange my own controls to accommodate the data? Would a formview work considering my source will be partially from both the main table and the detail table? This is one of the scenarios were I know I could come up with something using none of the databound controls (except the master gridview), but I want to use the controls provided when it makes sense to do so, and utilize their benefits etc...

View 6 Replies

ADO.NET :: How To Join 3 Related Tables With Linq To Sql

Nov 9, 2010

Here's my DB structure:

I have three tables.

User, Details, Optional
User has fields: ID, FirstName, LastName
Details has fields: ID, MyDetails1, MyDetails2, User_ID
Optional has fields: ID, MyOptions1, MyOptions2, User_ID
There is a 1 to many relationship with User & Detail (User ID & Detail User_ID)
There is a 1 to many relationship with User & Optional (User ID & Optional User_ID)

With that said, one user can have many details and/or many optionals

Now I'm trying to build a linq query that will say:

"where user id = x, select FirstName, LastName, all MyDetails1 from every record where User_ID == x, all MyOptions1 from every record where User_ID == x"

After the merge I should have one string that lists the distict user & all of their many fields:

FirstName + LastName + (MyDetails1 + MyDetails1 + MyDetails1..etc) + (MyOptions1 + MyOptions1)

Anyone try this before?

I tried this with JOIN but this doesn't do the trick for what I'm looking for.

So if I had 3 MyDetails records associated with ID == 2, I would get three results like:

John Doe MyDetails_X
John Doe MyDetails_Y
John Doe MyDetails_Z

View 1 Replies

Security :: Are The Aspnet_xyz Tables Linked / Related To The Membership Providers

Feb 16, 2011

After running the aspnet_regsql.exe tool, i notice a bunch of different tables pertaining to the ASPNET security (e.g. aspnet_Applications, aspnet_Membership, aspnet_Paths, aspnet_Personalations, aspnet_Profile, aspnet_Roles, aspnet_SchemaVersion, aspnet_Users, aspnet_UsersInRoles). Do the different providers (AspNetSqlMembershipProvider, AspNetSqlProfileProvider, AspNetSQLRoleProvider) relate or associated with certain aspnet_xyz tables? I imagine the AspNetSQLProfileProvider is responsible for the aspnet_Profile table correct? The AspNetSQLRoleProvider probably is tied to the aspnet_Users, aspnet_Roles, aspnet_UsersInRoles table? Any links documenting the relationship between teh providers and the aspnet_xyz tables?

View 1 Replies

ADO.NET :: Insert Into 3 Related Tables Using Three Tier Architecture And Typed Datasets

Aug 29, 2010

I am using ASP.NET (C# and sql server express 2005) for my web application project. I have three related tables. I want to do an insert using typed datasets,tableadapters and three tier architecture. I wish to know how to do simultaneous inserts in 3 tables. So i wish to insert a row in first table and get its primary key. Same with the second table. I will use the primary keys of those first two tables to do the insert in the third table. How can i accomplish this using formview control and what methods should i use??

View 3 Replies

Forms Data Controls :: 1 Gridview From 2 Or More Tables?

Oct 2, 2010

How do I create 1 gridview for data found in 2 or more seperate tables? Is that even possible?

I have a Customers Table and a Business Owners Table... I need to get at the data from both?

View 3 Replies

Forms Data Controls :: Gridview For All Tables?

Sep 30, 2010

I have a task to create grid view for 8 different tables. I am wondering if there is a better way to create those gridviews. The following features has to be in almost all 8 gridviews

1. Add / Edit / Delete / Sort
2. Some of the grid view has to contain a combo box when editing the row
3. A check box has to be in first column of the gridview
4. When editing the grid view, I need to have an edit form pop up
5. Confirm delete dialog box has to show before delete.It is not smart to create 8 grid views ( I am trying to avoid creating the grid manytimes)

View 3 Replies

Forms Data Controls :: Bind Gridview From Different Tables?

Jun 18, 2010

i want to bind gridview from different tables and as shown in following format only

Column1
Column2
Column3
Column4
Column5
Column6
Column7
Column8

View 3 Replies

Forms Data Controls :: Searching Through Gridview Using 2 Tables?

Jul 8, 2010

I have one gridview, a dropdown list where I can search the users table or a group name table, a textbox for inputting the search and a button to search.How could I overwrite the users table that is binded in the gridview when I search through the groupname table? Using C#.

View 2 Replies

Forms Data Controls :: Update Multiple Rows Of Gridview On Click Of Update Button?

Jul 10, 2010

I want to update multiple rows of gridview (only price field. for that i have added textbox) on click of update button which is outside of gridview.I have done following way

<asp:LinkButton ID="lnkUpdate" CssClass="BlueButton" runat="server" OnClick="lnkUpdate_Click">Update</asp:LinkButton>

[Code]....

Up to this its working fine but when no textbox updated then no need to go in for loop so i am looking for confiramtion before updating rows please help me how to do that becausei am less aware with javascript. another problem is textbox value disappear when page index changed how i can retain that values.

View 2 Replies

Forms Data Controls :: Gridview Update Mode Is Not Ending After Clicking On Edit Then Update?

Mar 23, 2011


[Code]....

View 8 Replies

Forms Data Controls :: Update A Row Using The Update Functionality Of Gridview?

Jun 28, 2010

When i try to update a row using the update functionality of Gridview it updates all the rows rather then updating that specific row which is in edit mode.

[Code]....

View 1 Replies







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