Datagrid.databind() causes "Object reference not set to an instance of an object" error

K

Karim

I have a datagrid with a collection of columns and the datagrid is
populated as in the code below. The value of test = 3 rows which is
correct. However I get an exception when the code hits the Databind line.
When I removed all the columns and dg is left with <columns></columns>, I
don't get an error. If there's any column in the collection no matter what
column it is, the error comes back. All the datafield names correspond to
the column names and the code worked before. What kind of troubleshooting
or debugging methods should I go about? The databind() seems to me like a
blackbox and it's doing stuff which I don't seem to be aware of.

TIA.


<asp:datagrid..... AutoGenerateColumns="False" DataKeyField="msid">
....
DataTable dtMembers = oMembers.SelectAll();
int test = dtMembers.Rows.Count;
dgMemberList.DataSource = dtMembers;
dgMemberList.DataBind();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top