c# - How to set headers for columns in DataGridView, where data is populated from a sql query -
i have following code working, want display own column names each column rather ones in database. there anyway can that?
sqlcommand cmd = new sqlcommand(); cmd.commandtype = commandtype.storedprocedure; cmd.commandtext = "total_registration"; cmd.connection = con; using (sqldataadapter = new sqldataadapter(cmd.commandtext, con)) { datatable t = new datatable(); a.fill(t); grid.datasource = t; }
after binding datasource set column header text explicitly
grid.datasource = t; grid.column["id"].headertext = "identifier";
Comments
Post a Comment