binding data with gridview
-
Hello Experts, I am designing columns in datagridview at design time and bind data at run time using dataset...But it shows in gridview my columns(designtime) and dataset column at a time. Waht to do with this? I dont want to change column header order!! It shows according to database column order!! Please help!!
-
Hello Experts, I am designing columns in datagridview at design time and bind data at run time using dataset...But it shows in gridview my columns(designtime) and dataset column at a time. Waht to do with this? I dont want to change column header order!! It shows according to database column order!! Please help!!
It is difficult to say, without seeing some code, but generally speaking when adding columns to a datagridview, you can determine all kinds of stuff per column, before you add it at run time. So you could look into resorting the columns at runtime after binding the data to them. Another possibility, is to change the select clause in your query, so that the order of the columns will already be correct in the dataset.
My advice is free, and you may get what you paid for.
-
Hello Experts, I am designing columns in datagridview at design time and bind data at run time using dataset...But it shows in gridview my columns(designtime) and dataset column at a time. Waht to do with this? I dont want to change column header order!! It shows according to database column order!! Please help!!
-
It is difficult to say, without seeing some code, but generally speaking when adding columns to a datagridview, you can determine all kinds of stuff per column, before you add it at run time. So you could look into resorting the columns at runtime after binding the data to them. Another possibility, is to change the select clause in your query, so that the order of the columns will already be correct in the dataset.
My advice is free, and you may get what you paid for.
-
Check to see if there is a GenerateColumns or an AutoGenerateColumns property and set it to false. You may need to write additional code to bind the design-time columns with the columns in the dataset.
-
ya we can reorder it using select query command, Thanks!! But i have another query is grid result show desigtime columns as well as runtime columns too!! Than how to solve this problem?
If I understood you correctly, it sounds like something is going wrong with the data binding. In other words, you have the columns from design time, and then when the data is bound during runtime, a new set of columns is created instead of the existing ones being used.
My advice is free, and you may get what you paid for.
-
ya we can reorder it using select query command, Thanks!! But i have another query is grid result show desigtime columns as well as runtime columns too!! Than how to solve this problem?
A couple of things to check... First, in your binding code, make sure that you set the DataGridView's AutoGenerateColumns property to False. Next, make sure your Columns that you created are setup properly to bind to the appropriate table/column names in the dataset/datatable.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
That autogenerate property coes into asp.net application but not in windows,i checked that one also!! Any other way?
KIDYA wrote:
That autogenerate property coes into asp.net application but not in windows
You might want to check again. DataGridView doesn't work under ASP.NET. It's a WindowForms only control. You can find the documentation on AutoGenerateColumns here[^].
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...