Click here to Skip to main content
16,005,149 members
Home / Discussions / Database
   

Database

 
Questionhow to open binary data type for image in access Pin
Anonymous18-Feb-03 10:38
Anonymous18-Feb-03 10:38 
GeneralRow-level locking Pin
Le centriste18-Feb-03 9:46
Le centriste18-Feb-03 9:46 
GeneralFound it! Pin
Le centriste21-Feb-03 17:02
Le centriste21-Feb-03 17:02 
GeneralDB Schema Decsions Pin
Jason McBurney18-Feb-03 7:51
Jason McBurney18-Feb-03 7:51 
GeneralRe: DB Schema Decsions Pin
perlmunger18-Feb-03 8:37
perlmunger18-Feb-03 8:37 
GeneralUsing the ODBC Provider seamlessly Pin
Andrew Torrance18-Feb-03 5:51
Andrew Torrance18-Feb-03 5:51 
QuestionHow to use Dataview and Datagrid to show fields from two different tables Pin
DotNetNewbie17-Feb-03 23:49
DotNetNewbie17-Feb-03 23:49 
AnswerRe: How to use Dataview and Datagrid to show fields from two different tables Pin
perlmunger18-Feb-03 8:04
perlmunger18-Feb-03 8:04 
I think you're trying to mix the way the data is displayed with what you are retrieving from the database. All you really need to do is set up the columns properly in your data grid and then simply bind the DataTable to the DataGrid as its data source. You don't need a DataView in this case.

On your DataGrid in the aspx page, set the AutoGenerateColumns property to false and then specify the columns you want to display in the Columns property. Only supply the columns that you want. So let's say that these are the columns your join returned:
CustID, CustName, UsagePeriod, DlyAmount, MnthlyAmount, Total

,but all you want to show are these:
CustName, UsagePeriod, DlyAmount, MnthlyAmount, Total

Just specify these columns in the Columns property in the properties panel (there's a button that opens a dialog where you add the columns).

Then your code would just look like this (this is C# code, but I think you get the idea):
C#
DataSet dataSet = new DataSet();
dataAdapter.Fill( dataSet,"TableName");
DataTable dataTable = dataSet.Tables[0];

dgUsage.DataSource = dataTable;
dgUsage.DataBind(); // Don't forget this!!

In this case the entire data set that you got from the database is still avialable. You are just diplaying the pertinent columns as specified in your Columns property.

You may have heard of separating your presentation from your data before, well this is an example of how to do so. Your DataSet, DataTable, etc. should never be aware or care about how you are displaying something. Just tell your DataGrid what to do with the data it has been handed by specifying the columns to use.

A DataView is more for filtering records (rows), not columns. If I understand you correctly, you want to display all but one of the columns from the join. Is that correct?

Hope this makes sense. Let me know if you need clarification. If I've missed something, let me know.

-Matt

------------------------------------------

The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
GeneralRe: How to use Dataview and Datagrid to show fields from two different tables Pin
DotNetNewbie18-Feb-03 10:36
DotNetNewbie18-Feb-03 10:36 
GeneralRe: How to use Dataview and Datagrid to show fields from two different tables Pin
perlmunger18-Feb-03 12:26
perlmunger18-Feb-03 12:26 
GeneralRe: How to use Dataview and Datagrid to show fields from two different tables Pin
DotNetNewbie18-Feb-03 23:05
DotNetNewbie18-Feb-03 23:05 
GeneralText Field as Identity in Access Pin
perlmunger17-Feb-03 7:55
perlmunger17-Feb-03 7:55 
GeneralBook Recommendations Pin
Mark Sanders17-Feb-03 4:46
Mark Sanders17-Feb-03 4:46 
GeneralDatagrid and Dataset questions Pin
DionChen17-Feb-03 4:01
DionChen17-Feb-03 4:01 
GeneralRe: Datagrid and Dataset questions Pin
perlmunger18-Feb-03 13:05
perlmunger18-Feb-03 13:05 
GeneralDB's on Servers Pin
RichardS16-Feb-03 21:39
RichardS16-Feb-03 21:39 
GeneralRe: DB's on Servers Pin
Hesham Amin17-Feb-03 21:43
Hesham Amin17-Feb-03 21:43 
GeneralSyntax error with CREATE TABLE Pin
IrishSonic16-Feb-03 1:41
IrishSonic16-Feb-03 1:41 
GeneralRe:Found my problem but need to be able to create table for 600 chars Syntax error with CREATE TABLE Pin
IrishSonic16-Feb-03 2:12
IrishSonic16-Feb-03 2:12 
GeneralRe:Found my problem but need to be able to create table for 600 chars Syntax error with CREATE TABLE Pin
karl_w16-Feb-03 3:17
karl_w16-Feb-03 3:17 
GeneralRe:Found my problem but need to be able to create table for 600 chars Syntax error with CREATE TABLE Pin
David Salter16-Feb-03 10:44
David Salter16-Feb-03 10:44 
GeneralThanks. Pin
IrishSonic17-Feb-03 9:58
IrishSonic17-Feb-03 9:58 
GeneralConvert ORACLE functions Pin
Andy H15-Feb-03 23:30
Andy H15-Feb-03 23:30 
GeneralRe: Convert ORACLE functions Pin
jamesr337816-Feb-03 5:38
jamesr337816-Feb-03 5:38 
GeneralRe: Convert ORACLE functions Pin
Andy H16-Feb-03 6:12
Andy H16-Feb-03 6:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.