Reputation: 9961
I got an error when run datagridview.DataSource = dataView; dataview is correct. I can see data inside it when I debug program.
I got next error "Object reference not set to an instance of an object."
Any Ideas?
code:
this.datagridview = new System.Windows.Forms.DataGridView();
...
DataSet ds = new DataSet();
XmlReaderSettings settings = new XmlReaderSettings();
StringReader stringReader = new StringReader(retString);
XmlReader xmlReader = XmlReader.Create(stringReader, settings);
ds.ReadXml(xmlReader);
DataView dataView = ds.Tables[0].DefaultView;
dataView is not null. I am able to view it when debug
Upvotes: 1
Views: 2639
Reputation: 54999
Is all you code in the same method, or is the initialization of the DataGridView
in a InitializeComponent
method?
If it's in a InitializeComponent
method, make sure that your other code is called after that method has been called. Check that if you've got a constructor for your Control
that it calls InitializeComponent
.
Upvotes: 1