Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataSet not declared error. Newbie

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
So, here is my ASPX page (html). I built this in VB .NET. I used the Data controls to connect to the database (Access) Got a DBDataAdapter, DBConnection, and dataset in the screen. How do I see what is in the codebehind? When I built the dataset why doesn't it show up in this code? What am I doing wrong?

<%@ Import Namespace=&quot;System.Data.OleDb&quot; %>
<%@ Import Namespace=&quot;System.Data&quot; %>
<HTML>
<HEAD>
<title>New Page 1</title>
<script language=&quot;vb&quot; runat=&quot;server&quot;>
Sub Page_Load(Sender As Object, E as EventArgs)

End Sub
</script>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<meta content=&quot;Microsoft FrontPage 4.0&quot; name=&quot;GENERATOR&quot;>
<meta content=&quot;FrontPage.Editor.Document&quot; name=&quot;ProgId&quot;>
</HEAD>
<body>
<form id=&quot;newForm&quot; method=&quot;post&quot; runat=&quot;server&quot;>
<asp:datagrid id=DataGrid1 runat=&quot;server&quot; AllowSorting=&quot;True&quot; DataSource=&quot;<%# dataSet1 %>&quot;>
<HeaderStyle BorderStyle=&quot;Outset&quot; BorderColor=&quot;Black&quot; BackColor=&quot;#FFC080&quot;></HeaderStyle>
<SelectedItemStyle BorderColor=&quot;Red&quot;></SelectedItemStyle>
<AlternatingItemStyle BackColor=&quot;#E0E0E0&quot;></AlternatingItemStyle>
</asp:datagrid>
</form>
</body>
</HTML>
 
Just think of VB 6. One way to get there is to double click a control. The IDE will then make a Event handler sub for you within the code behind. The other way to get to the code behind is to press F7 while viewing the page that you wish to code for. Remember you will need to bind your grid in the code behind page_onload in order for it to display anything.

Any other questions feel free to ask. That'l do donkey, that'l do
[bravo]
 
I hit F7 and nothing happens. What should the codebehind page look like?
 
Lets talk about how you created this page first:

Did you creat a new WebForm (.aspx), or did you start with a blank html page and add the coding from tehre?

The reason I ask is that if you create a new WebForm within vs.net, it will automatically create teh .vb code behind file for you, AND add the declaration that links the .aspx page to the .vb code behind; i noticed that declaration is missing from your html page.

Fill us in on how you created the page, and we can take it from there.

Jack
 
I believe I opened a page that I had previously created... and modified from there.
 
As Jack was saying it seems most likely that you didn't actually create a web form page then.
At the very top of your web form page there should be a line that looks something like this
<%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Codebehind=&quot;AddCreditCard.aspx.vb&quot; Inherits=&quot;RoamingForest.AddCreditCard&quot;%>


If you want to write all of your code by hand you can, although that would be ignoring the main point of the VS IDE.
You may want to create a new page by going to file - AddNewItem. Choose to add a webform. This will add a web form to your project that includes the code behind.
Alternatively you can add the line above to your current page and create a aspx.vb file for it as well.

HTH
That'l do donkey, that'l do
[bravo]
 
k, thats why you don't have a code behind: you havn't created a page to link your aspx page to (your current page does have a .aspx suffix right?).

Here's what you need to do:
1. Create a .vb or .cs code file
2. Name that file YourPageName.aspx.vb
3. Create a class in that file (you can call it whatever
you want, but vs.net usually names it the same thing as
the page)
4. Add this line to your page:
<%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Codebehind=&quot;YourPageName.aspx.vb&quot; Inherits=&quot;projectname.theclassnameyouentered&quot; %>


Now doing it this way also means you need to add a WithEvents statement for each control you have, etc. etc.

OR

Since your page doesn't look overly complicated, you may just want to create a new page. The time it would take you to hook up a new page would be comparable to trying to create a code behind from scratch, and probably less errors.

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top