473,431 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,431 software developers and data experts.

Blank Web Page

Hello all, could someone explain why I'm getting a blank web page when I run
start my code in a web browser? Here is the code:
Imports System.Data.SqlClient
Imports System.Data
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

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

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Create the data connection.
Dim sqlconnectContactMgmt As New SqlConnection _
("server=(local);database=Contacts;Trusted_Connect ion=yes")
'Create a data adapter.
Dim sqladaptContactMgmt As New _
SqlDataAdapter("select * from Contacts", sqlconnectContactMgmt)
'Create a data set.
Dim dsContacts As New DataSet()
'Fill in the data set.
sqladaptContactMgmt.Fill(dsContacts, "Contacts")
'Display the table in a data grid using data binding.
Dim DataGrid1 As New DataGrid()
DataGrid1.DataSource = dsContacts.Tables("Contacts").DefaultView
DataGrid1.DataBind()

End Sub
End Class
Nov 19 '05 #1
1 1433
This line of code:

Dim DataGrid1 As New DataGrid()

is creating a new DataGrid which it goes on to bind the data to. Unfortunately,
if you just create a grid in this fashion it is not attached to the web form.
A web form has to 'know' about a DataGrid in order to display the grid, and
just creating a grid like this doesn't let the page know about the grid.

Are you using Visual Studio.NET? If so, you'll want to drag and drop a DataGrid
control onto the web form. Visual Studio will put a grid into the form and
give you a variable in the code behind to match. All you'll need to do then
is set the DataSource property and call DataBind (like you have below).

Making sense?

--
Scott
http://www.OdeToCode.com/blogs/scott/
Hello all, could someone explain why I'm getting a blank web page when
I run
start my code in a web browser? Here is the code:
Imports System.Data.SqlClient
Imports System.Data
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

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

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Create the data connection.
Dim sqlconnectContactMgmt As New SqlConnection _
("server=(local);database=Contacts;Trusted_Connect ion=yes")
'Create a data adapter.
Dim sqladaptContactMgmt As New _
SqlDataAdapter("select * from Contacts",
sqlconnectContactMgmt)
'Create a data set.
Dim dsContacts As New DataSet()
'Fill in the data set.
sqladaptContactMgmt.Fill(dsContacts, "Contacts")
'Display the table in a data grid using data binding.
Dim DataGrid1 As New DataGrid()
DataGrid1.DataSource =
dsContacts.Tables("Contacts").DefaultView
DataGrid1.DataBind()
End Sub

End Class

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: dmcconkey | last post by:
Hi folks, I have a client with four websites. Each site has a contact form that is identical. They all have "required" fields validated through a JavaScript onSubmit() function. Upon validation,...
2
by: Ravi | last post by:
I have a webpage(with a text field and a button) which prompts for a local file and attempts to load the file in the window if the user clicks on the button. The javascript code onClick event uses...
2
by: Michael | last post by:
All, I have a form send a variable to another page. Based on the variable the page will show a different image. I.E. <form METHOD="POST" ACTION="http://mysite.com/photo.htm"> <input...
14
by: charlie_M | last post by:
Is there a way to blank the screen in a FORM's onsubmit=... to blank the screen for the user?? I asked this before and got a way to blank a table by id with ...
6
by: Melissa | last post by:
Does anyone have a generic procedure for adding blank lines to reports like Sales details, PO details and/or Orders details. The procedure would need to count the number of line items, determine...
4
by: Nhmiller | last post by:
Access seems to always generate a second page, which is blank, to my one page report. How do I delete the second page? Thanks. Neil Cat Paintings At Carol Wilson Gallery...
6
by: noway | last post by:
I have greated a report and have included a page break in it. The report breaks were it is supposed to but then it creates a blank page between the two pages. Since this report will print out...
3
by: Wayne | last post by:
I have a report containing 2 subreports. The subreports each contain a chart. The whole thing easily fits on one page but a second blank page is consistently being generated. This has nothing...
1
by: siomay87 | last post by:
please help i have a problem in the ms access reporting, my report have: page header, detail, page footer and report footer In listing "detail section", the number of line is depend on the data...
4
by: sid | last post by:
"about:blank" oepns new browser window I am writing a webpage that will run on other machines that I may or may not know about. My page is framed where frame1 controls the content of frame2. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.