Question:
VB .NET 2005 DataGridView column header text problem?
2007-03-12 12:35:23 UTC
I have an unbound DataGridView control on my form. I manually set up its 2 columns in the Columns property (to give the column headers a better text say "Country ID" and "Country Name")

Now, I create a DataAdapter and use its Fill method to populate a DataSet with all the records in the Countries table (having two fields: country_id, country_name) and set the DataSource of the DataGridView to the DataSet.

The problem is that, the two columns that i created are left blank and two more columns are added to the DataGridView and the actual data is shown in those columns. I don't like it this way because their headers show up the actual attribute names "country_id" and "country_name".

How can i display the data in the columns i created earlier with proper formatting OR if I dont create the columns, then how can I change the header text to something like "Country ID" and "Country Name" ???

Any help will be highly appreciated...!!

Thanks in advance
Three answers:
solitaryfalcon
2007-03-12 12:50:59 UTC
Your data grid should look something like this:


AutoGenerateColumns="False"

runat="server" >




DataField="country_id"

HeaderText="Country ID">




DataField="country_name"

HeaderText="Country Name">









Set AutoGenerateColumns to False so the grid won't add the columns automatically after being bound to the data.
Smutty
2007-03-12 13:51:10 UTC
since you already added the two columns manually, all that remains to do is to set the AutoGenerateColumns of the GridView to false













?
2016-11-25 03:49:23 UTC
only as each little thing approximately enhance, there are various possibilities in right here. you ought to use a MS get admission to Database wich is basic to apply, and it could artwork with an significant volume of documents, it relies upon to boot, it this documents is gonna be used via purely one person at a time, in case you like it to be multiuser you will must be carefull on your courses to guard the integrity of the innovations. yet whilst your documents is definitely huge and want something professional, you migth choose to apply something extra preserve and good as MS sq. Server. possibly you choose to apply something like MySQL wich is extra used in case you're working with internet enhance, and that i think that's basic to apply.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...