Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,556 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,342 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Changing Column order in gridView bound to data

 
Reply to this topicStart new topic

Changing Column order in gridView bound to data, need to display different order to what is returned

Footsie
post 15 Jul, 2008 - 01:19 AM
Post #1


D.I.C Regular

Group Icon
Joined: 20 Sep, 2007
Posts: 279



Thanked 2 times

Dream Kudos: 50
My Contributions


I'm using C# and SQL server 2005 express as the database.

I need the order displayed in the gridView to be as it is in the sql code ie: Customers.Companyname must appear as the first column and Suppliers.SupplierName after the column UnitPriceExVat.

But at the moment both of these columns are appearing as the last two columns in the gridView.

How can I rectify this?

This is the SQL:
sql

SELECT Customers.CompanyName, Orders.Qty,
Orders.OrderDescription,
Orders.UnitPriceExVAT, Suppliers.SupplierName,
Orders.OrderDate, Orders.Action, Orders.Printer,
Orders.ETA_Printer, Orders.Courier,
Orders.RequiredDate, Orders.Invoiced
FROM Orders INNER JOIN
Suppliers ON Orders.SupplierID = Suppliers.SupplierID INNER JOIN
Customers ON Orders.CustomerID = Customers.CustomerID
WHERE (Orders.Invoiced = @paramBool)
ORDER BY Customers.CompanyName DESC


In my Form1:
csharp

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace AgeAfrica
{
public partial class Form1 : Form
{
//private field called order, and property for it
private BusinessLogicLayer.OrdersBLL order = null;
protected BusinessLogicLayer.OrdersBLL NewOrder
{
get
{
if (order == null)
{
order = new BusinessLogicLayer.OrdersBLL();
}
return order;
}
}

public Form1()
{
InitializeComponent();
//get orders already invoiced, display in gridview
gridView1.DataSource = NewOrder.getOrdersByInvoiced(true);
}
}
}
User is offlineProfile CardPM

Go to the top of the page


Footsie
post 22 Jul, 2008 - 07:04 AM
Post #2


D.I.C Regular

Group Icon
Joined: 20 Sep, 2007
Posts: 279



Thanked 2 times

Dream Kudos: 50
My Contributions


Am I wrong in thinking that the columns should be returned in the same order as the SELECT statement is written?

When I added the GetOrdersByInvoiced(@paramBool) method to the OrderTableAdapter (this is the method in the DAL that the getOrdersByInvoiced method calls) I get a textbox saying that the Schema differs from the main query and table. Could this be the problem?

Should I be looking at using views to show the correct format?


User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 11:09PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month