data grid view column name

i have a data grid view that is bound to my data in ms sql 2005 now i want that the column names that i retrieve from the dbase be changed to my customised column names and this may not create inconsistencies in the the dbase.

sample codes are welcome.



Answer this question

data grid view column name

  • Karen Liu MSFT

    Hi,

    I also would like to add, if you use sqldatasource in your datagridview..in its collection located in the property window of your datagridview you can change the header text of each column to the name you like...

    thanks....



  • kobe082005

    well yes that is an option but i am using different sql statements every time thus it takes time to alter every statement so what i really weant is that at the load of the gridview i would like to change the  column name from the db to my customized column name so that the grid_load  checks for them just once and alters the names as and when they occour

    is this confusing...

    by the way thanks for ur reply

    one more thing i have a dropdownlist box that i populate  using an sql statement so as to select the column names but if i use aliasing i am not able to retreve values stored in the particular column name coz it goes in search of the  data from alias  name which clearly does not exist. the idea behind renaming these columns is to maintain discreetness between the user and the db.


  • StephenGB

    Hi,

    I would like to help you about your problem...I think one way of solving your problem is through your SQL statement.. In your SQL statement you can customized the name of its fields, using alias to every field you retrieved from your database...I'm sure you you know sql statment very well..

    Hope I have helped you with your problem....if not feel free to reply to my post... I will appreciate that very much.... thanks.....



  • data grid view column name