Hi,
dr looks like it is populated but I get a nullreferenceexeception when I try to bind to the gridview
EDIT The following code (except the GridView is a dataGridView) in a c# application works, why is it nullreference in ASP.NET?
EDIT here is the c# app
SQLiteConnection cnn = new SQLiteConnection("Data Source=c:\\log.db");
SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM evtlog", cnn);
cnn.Open();
SQLiteDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
DataTable dt = new DataTable();
dt.Load(dr);
dataGridView1.DataSource = dt;
Thanks
code
SQLiteConnection cnn = new SQLiteConnection("Data Source=c:\\log.db");
SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM evtlog", cnn);
cnn.Open();
SQLiteDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
DataTable dt = new DataTable();
dt.Load(dr);
GridView1.DataSource = dt;
GridView1.DataBind();
Codebehind
<asp:ContentPlaceHolder ID="MainContent" runat="server">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</asp:ContentPlaceHolder>
error
Object reference not set to an instance of an object.
at WPKG_Report.SiteMaster.Button1_Click(Object sender, EventArgs e) in C:\Projects\Report\Site.Master.cs:line 32 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)