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

Discussion in 'ASP .Net' started by Karim, Jun 10, 2005.

  1. Karim

    Karim Guest

    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();


    --
    John Dalberg
    Karim, Jun 10, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Parthiv Joshi
    Replies:
    2
    Views:
    669
    Kalyan
    Jul 2, 2004
  2. Suresh Kojhani
    Replies:
    1
    Views:
    2,362
    Anushi
    Jul 29, 2004
  3. Lauchlan M
    Replies:
    1
    Views:
    2,348
    S. Justin Gengo
    Aug 18, 2003
  4. Tim Zych
    Replies:
    2
    Views:
    537
    Andy Gaskell
    May 15, 2004
  5. Replies:
    1
    Views:
    464
    Mark Rae [MVP]
    Sep 20, 2007
Loading...

Share This Page