Dear All,
I am new to Asp.net and facing some issues while coding:
i am using Visual Studio 2010 - Vb.net & Sql Server 2008
Trying to Do :
I have a WebForm ("frmLocations.aspx") and User Control ("cltGrids.ascx")
User Control has two Data Grids
i want to Bind Values to datagrid here is my code
Error
I am getting error on pointer - grid1.DataSource = dt
error message
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=EPayments
StackTrace:
at EPayments.frmLocations.RefreshGrid() in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\EPayments\EPayments\Setups\frmLocations.aspx.vb:line 28
at EPayments.frmLocations.Page_Load(Object sender, EventArgs e) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\EPayments\EPayments\Setups\frmLocations.aspx.vb:line 20
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
Pls assist
Thanks
I am new to Asp.net and facing some issues while coding:
i am using Visual Studio 2010 - Vb.net & Sql Server 2008
Trying to Do :
I have a WebForm ("frmLocations.aspx") and User Control ("cltGrids.ascx")
User Control has two Data Grids
i want to Bind Values to datagrid here is my code
VB.NET:
Imports System.Data.SqlClient
Public Class frmLocations
Inherits System.Web.UI.Page
Dim clsSetup As New clsSetup
Dim clsUsers As New clsUsers
Dim cltGrid As New cltGrids
Dim grid1 As New DataGrid
Dim grid2 As New DataGrid
Dim strConnString As String = System.Configuration.ConfigurationManager.ConnectionStrings("conString").ConnectionString
Dim con As New SqlConnection(strConnString)
Dim dt As New DataTable
Dim Sql As String = ""
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
grid1 = CType(cltGrid.FindControl("GridView1"), DataGrid)
grid2 = CType(cltGrid.FindControl("GridView2"), DataGrid)
Call RefreshGrid()
End Sub
Sub RefreshGrid()
Sql = clsSetup.LocationGrid_SQL("ALL")
dt = clsSetup.populateGrid(Sql)
grid1.DataSource = dt
grid1.DataBind()
Sql = clsSetup.LocationGrid_SQL("Pending")
dt = clsSetup.populateGrid(Sql)
grid2.DataSource = dt
grid2.DataBind()
End Sub
End Class
Error
I am getting error on pointer - grid1.DataSource = dt
error message
System.NullReferenceException was unhandled by user code
Message=Object reference not set to an instance of an object.
Source=EPayments
StackTrace:
at EPayments.frmLocations.RefreshGrid() in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\EPayments\EPayments\Setups\frmLocations.aspx.vb:line 28
at EPayments.frmLocations.Page_Load(Object sender, EventArgs e) in C:\Users\Administrator\Documents\Visual Studio 2010\Projects\EPayments\EPayments\Setups\frmLocations.aspx.vb:line 20
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
Pls assist
Thanks