Solved

DataGridView in windows form not showing results when autogeneratecolumns is set to false, when binding to a generic list.

Posted on 2008-10-13
5
384 Views
Last Modified: 2013-12-17
Hi,

I am mainly an asp.net developer but recently I have been working on a small windows application and was struggling to get data to display on a DataGridView control when using AutogenerateColumns set to false.

If I set AutogenerateColumns to true it works perfectly, but why is it not working when I manually set the columns?

Is there something extra that you need to do when using set columns?

0
Comment
Question by:jazz__man
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22701236
refer this example and compare  your your code... and put missing part in your code
http://msdn.microsoft.com/en-us/library/y0wfd4yz.aspx
0
 
LVL 2

Author Comment

by:jazz__man
ID: 22701367
BondinASP:
I used the designer to create the columns, whereas your example does everything in code. Is there a difference in using the designer?

I just don't understand why something as simple as creating your own column headers should make it not work. I have worked with Datagrids and Gridviews extensively in asp.net but cannot seem to get things working in a DataGridView.

The DataGridView expands as if it has brought back data but all the fields are blank.

Its weird, because if I take the columns out and set AutoGenerateColumns back to true everything works.
0
 
LVL 16

Accepted Solution

by:
Gyanendra Singh earned 500 total points
ID: 22703989
azz__man:

you need to set column.DataPropertyName = "filedname"; property.. this is a key if you are using
AutoGenerateColumns  false
0
 
LVL 2

Author Closing Comment

by:jazz__man
ID: 31505557
Thanks, that was the bit that was missing.
0
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22709323
your welcome
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do ASP.NET and MVC work together? 4 27
vb.net - How to check if current user is an administrator? 6 34
VB.Net How to Exit Sub - Exit Form??? 5 51
Run time Error 4 34
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now