Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2008
    Posts
    3

    Unanswered: distinct not showing. Kinda URGENT!

    Quick question, I have a sql query with a distinct at the start of it. Its being put into a gridview in c# but I don't want the first column to show.

    I've tried GridView2.Columns[0].Visible = true; but that hides the column with the Select button which I need. Column[1] throws back an error.

    Any Ideas?

    Much Thanks :-)
    Last edited by darran55; 01-20-08 at 20:44.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    So you want to see that column, but not see it? Or do you want to not see it, but see it? As you probably noticed, I'm rather confused trying to understand what you want.

    As far as I can tell, the issue is completely "client side" in your code. I don't see how SQL is any part of your problem. Coach me if I'm confused on this.

    -PatP

  3. #3
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    re

    Do you do a .bind
    If you do then you cant do what you want

    You´ll have to difine each column with a value
    Then you have what you want

  4. #4
    Join Date
    Jan 2008
    Posts
    3
    Basicially:
    string sCommand = "SELECT DISTINCT ISBN, Title, Genre, ISBN....
    linking to an orders and customers table too.

    SqlDataAdapter data = new SqlDataAdapter();
    data.SelectCommand = new SqlCommand(sCommand, connection);

    DataSet dset = new DataSet();
    data.Fill(dset);
    data.Dispose();
    GridView2.DataSource = dset;
    GridView2.DataBind();


    I need distinct isbn numbers, but don't want them in column 1 of a gridview. I know this is a SQL/C# mix of a question.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by darran55
    I need distinct isbn numbers, but don't want them in column 1
    SELECT DISTINCT 937, Title, Genre, ISBN, ...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jan 2008
    Posts
    3
    The result of the query comes back with many isbn numbers.
    That still doesn't hide the first column.

  7. #7
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450
    Your problem lies here :
    Quote Originally Posted by darran55
    GridView2.DataBind();

    You have to loop trough your dataset but first add your columns to the grid

    var col = new FGridColumn( "ID" );

    col.setEditable( false );
    col.setHeader( "ID" );
    col.setCellSymbol( "ID" );
    col.visible = false
    grid.addColumn( col );

    ect ect

    PS Hope this is a typeO
    Quote Originally Posted by darran55
    GridView2.Columns[0].Visible = true
    SHould this be ...
    GridView2.Columns[0].Visible = FALSE
    Last edited by Marvels; 01-21-08 at 07:47.
    Greetz Marvels -^.^-
    Developments : VB4 Through .Net; Basic; DOS ; CNC ; Sinclair
    Databases : SQL Server Through 2005; Access 3 Through 2003 ; Oracle 8 & 9.i ;
    OS : Win 3.11 Through XP ; NortonComander ; DOS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •