im trying to fill my datagrid but when the page loads in the browser you cant even see it.
wots going on there then here is the code,
Imports System
Imports System.data
Imports System.Data.SqlClient
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents txt_mobile_number As System.Web.UI.WebControls.TextBox
Protected WithEvents txt_name As System.Web.UI.WebControls.TextBox
Protected WithEvents btn_submit As System.Web.UI.WebControls.Button
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
' declare the data set and data adapters
Private dsUsers As New DataSet
Private daUsers As New SqlDataAdapter
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub loadusers()
'connect to database
Dim oSQLConn As SqlConnection = New SqlConnection
oSQLConn.ConnectionString = "Data Source=(local);" & _
"Initial Catalog=Con_Test;" & _
"Integrated Security=SSPI"
oSQLConn.Open()
'databind the infromation
'If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
daUsers.SelectCommand = New SqlCommand("SELECT * from table_user", oSQLConn)
daUsers.Fill(dsUsers, "Mobile")
DataGrid1.DataSource = dsUsers.Tables(0)
DataGrid1.DataBind()
oSQLConn.Close()
'daUsers.Fill(dsUsers)
'DataGrid1.DataSource = dsUsers.Tables(0)
End Sub
End ClassDoes your dataset contain any data ?
If there is no row in the DataTable, you will not see the Datagrid on the page.
im trying to fill my datagrid but when the page loads in the browser you cant even see it.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
What else do you expect with an empty Page_Load event :p
ii called loadusers now in the page load an now i am gettin an error that
'invalid object name table_user', thats the table name within Con_test.
:eek2:
Has it been spelt right in the database?
top man mendhank, i know it seemed obvious with the error message but i never would have checked it,
u da man
Not a problem, we all learn... :)
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment