E
ElanKathir
I am faceing problem in the Execution of server Script. Error and Code pasted here..
Please help me !
Thanks & Regards,
Elankathir.
---------------------------------------Code------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objDataSet As New DataSet()
Dim x As DataRow
Dim dt As New DataTable()
Dim dr As DataRow
' For Dynamic Dataset without Database
dt.Columns.Add("txt1", Type.GetType("System.String"))
dt.Columns.Add("txt2", Type.GetType("System.String"))
dr = dt.NewRow
dr("txt1") = "Kathir"
dr("txt2") = "Elan"
dt.Rows.Add(dr)
objDataSet.Tables.Add(dt)
DataGrid1.DataSource = objDataSet
DataGrid1.DataBind()
End Sub
----------------------------------------Error-----------------------------------------------------------
Server Error in '/Elan_Sample' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 43: dt.Rows.Add(dr)
Line 44: objDataSet.Tables.Add(dt)
Line 45: DataGrid1.DataSource = objDataSet
Line 46: DataGrid1.DataBind()
Line 47: For Each x In objDataSet.Tables(0).Rows
Source File: C:\Project Files\Root\Elan_Sample\WebForm1.aspx.vb Line: 45
Please help me !
Thanks & Regards,
Elankathir.
---------------------------------------Code------------------------------------------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objDataSet As New DataSet()
Dim x As DataRow
Dim dt As New DataTable()
Dim dr As DataRow
' For Dynamic Dataset without Database
dt.Columns.Add("txt1", Type.GetType("System.String"))
dt.Columns.Add("txt2", Type.GetType("System.String"))
dr = dt.NewRow
dr("txt1") = "Kathir"
dr("txt2") = "Elan"
dt.Rows.Add(dr)
objDataSet.Tables.Add(dt)
DataGrid1.DataSource = objDataSet
DataGrid1.DataBind()
End Sub
----------------------------------------Error-----------------------------------------------------------
Server Error in '/Elan_Sample' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 43: dt.Rows.Add(dr)
Line 44: objDataSet.Tables.Add(dt)
Line 45: DataGrid1.DataSource = objDataSet
Line 46: DataGrid1.DataBind()
Line 47: For Each x In objDataSet.Tables(0).Rows
Source File: C:\Project Files\Root\Elan_Sample\WebForm1.aspx.vb Line: 45