locked
get rid of columns RRS feed

  • Question

  • may i know how to get rid of the gridview column?

    i am using the rowfilter for gridview

    select * FROM TABLE A;

    <METHOD>

    case "existing ":

    filter = "do_id <>''";

          break;

    case "completed ":

    filter = "project_status='done'";

    break;

    case "payment":

    filter = "payment_status = 1";

    break;

    default:

    filter = "";

    break;

    }

    dataview.RowFilter = filter;


    for each of the case above, if fulfilled, i would like to populate only certain columns into the gridview instead of all the columns as "select * FROM TABLE A" .

    how do i get rid of the rest of the columns?


    i wanted to do somethings like below... but fails... pls hlep


     dgFind.Table.Columns["cust"].ColumnMapping = MappingType.Hidden;
     
    dgFind.Table.Columns["po_id"].ColumnMapping = MappingType.Hidden;
     
    dgFind.Table.Columns["do_id"].ColumnMapping = MappingType.Hidden;
     
    dgFind.Table.Columns["att"].ColumnMapping = MappingType.Hidden;
     
    dgFind.Table.Columns["amount"].ColumnMapping = MappingType.Hidden;
                         




    alain
    Friday, August 29, 2008 3:30 AM

Answers

  • oopss.. 
    instead of using this 
    dgFind.Table.Columns["cust"].ColumnMapping = MappingType.Hidden;

    i would suggest this
    dgAdvanceFind.Columns["cust"].Visible = false;

    Done. thanks

    alain
    • Marked as answer by kkkJoe Sunday, August 31, 2008 12:09 AM
    Saturday, August 30, 2008 5:19 AM

All replies

  • I am a little confused by you question but i think you are trying to get rid of extra columns....

    this property might be of use to you


    'AutoGenerateColumns' SET THIS PROPERTY TO FALSE

    AutoGenerateColumns=false


    Also please have a look at the following URL


    http://forums.asp.net/t/990661.aspx

    http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/GridViewClassAutoGenerateColumns.aspx


    Regards
    Junaid Arif
    Friday, August 29, 2008 5:26 AM
  • hi .. i am not able to find the autoGeneratecolumns property .. i can see only the autosizerowsmode and teh autosizecolumnsmode.

    sorry for confusing u .. let me rephrase.

    i have ONE gridview with the query as
     SELECT * FROM TABLE A;

    i added 10 columns for that gridview to cater for the value selected from table A.


    however, i would like to use back that gridview for my other query as
    SELECT name, add, phone FROM TABLE A;
    which only use up 3 columns of that gridview .

    THUS,i need to do some hidden work to hide the other 7 columns from appearing in the SAME gridview

    am i able to do this??

    alain
    Friday, August 29, 2008 6:00 AM
  • oopss.. 
    instead of using this 
    dgFind.Table.Columns["cust"].ColumnMapping = MappingType.Hidden;

    i would suggest this
    dgAdvanceFind.Columns["cust"].Visible = false;

    Done. thanks

    alain
    • Marked as answer by kkkJoe Sunday, August 31, 2008 12:09 AM
    Saturday, August 30, 2008 5:19 AM