Hi
Just wondering if anyone can help.
Still starting out in ASP.NET using VB.
Just learnt how to pull data in to a web page using a datagrid.
I'm having problems pulling in data to another part of the page outside of the datagrid.
Tried to create another datagrid and error message told me that there was already a datagrid in that web page.
The data is passed over to another web page from a querystring using the primary key from the table I'm accessing.
I can make the connection fine. I can create the table and relevant info from that table into a table on the web page.
What I want is to be able to pull in another bound field at the top of the page that relates to the table I'm connected to.
The table consists of the following fields: AdNum (Primary Key) / Title / Category / Description / Price.
I want to put the 'Title' field at the top of my page outside of the datagrid.
Part of the code is:
Header.Text = "Title: " & AdNumSent
I would like it to say:
Header.Text = "Title: " & Title
Thank you for any help.
The code is as follows
<%@ Page Explicit="True" Debug="True" Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.OleDB" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack Then
Dim Connect As OleDbConnection = New OleDbConnection
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter
Dim ClassyDS As DataSet = New DataSet
Dim ConnectString, SelectStatement As String
Dim AdNumSent As Integer
AdNumSent = Request.QueryString("AdNum")
SelectStatement = "Select * From Ads Where AdNum=" & AdNumSent
Header.Text = "Title: " & AdNumSent
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\inetpub\
Connect.ConnectionString = ConnectString
Adapter.SelectCommand = new OleDbCommand(SelectStatement, Connect)
Adapter.SelectCommand.Connection.Open
Adapter.Fill(ClassyDS, "Ads")
AdsGrid.DataSource = ClassyDS.Tables("Ads")
Page.DataBind
End If
End Sub
</script>
<head>
<title>Details</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body vlink="#990000">
<asp:Label ID="Header" runat="server" Font-Size="18 pt" Font-Bold="true" />
<br>
<br>
<aspataGrid ID="AdsGrid" runat="server" AutoGenerateColumns="false"
Border="1" BackColor="#FFFF00" Width="100%" BorderColor="#000000" CellSpacing="0" CellPadding="5">
<columns>
<asp:BoundColumn
HeaderText="Title"
datafield="Title">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Price"
datafield="Price">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="State"
datafield="State">
</asp:BoundColumn>
</columns>
</aspataGrid>
<br>
<center>
<asp:HyperLink ID="HomeLink" runat="server" NavigateUrl="default.aspx" Font-Bold="true" Font-Name="verdana" Font-Size="12 pt">
[ Home ]
</asp:HyperLink>
</center>
</body>
</html>
Just wondering if anyone can help.
Still starting out in ASP.NET using VB.
Just learnt how to pull data in to a web page using a datagrid.
I'm having problems pulling in data to another part of the page outside of the datagrid.
Tried to create another datagrid and error message told me that there was already a datagrid in that web page.
The data is passed over to another web page from a querystring using the primary key from the table I'm accessing.
I can make the connection fine. I can create the table and relevant info from that table into a table on the web page.
What I want is to be able to pull in another bound field at the top of the page that relates to the table I'm connected to.
The table consists of the following fields: AdNum (Primary Key) / Title / Category / Description / Price.
I want to put the 'Title' field at the top of my page outside of the datagrid.
Part of the code is:
Header.Text = "Title: " & AdNumSent
I would like it to say:
Header.Text = "Title: " & Title
Thank you for any help.
The code is as follows
<%@ Page Explicit="True" Debug="True" Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.OleDB" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If Not IsPostBack Then
Dim Connect As OleDbConnection = New OleDbConnection
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter
Dim ClassyDS As DataSet = New DataSet
Dim ConnectString, SelectStatement As String
Dim AdNumSent As Integer
AdNumSent = Request.QueryString("AdNum")
SelectStatement = "Select * From Ads Where AdNum=" & AdNumSent
Header.Text = "Title: " & AdNumSent
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\inetpub\
Connect.ConnectionString = ConnectString
Adapter.SelectCommand = new OleDbCommand(SelectStatement, Connect)
Adapter.SelectCommand.Connection.Open
Adapter.Fill(ClassyDS, "Ads")
AdsGrid.DataSource = ClassyDS.Tables("Ads")
Page.DataBind
End If
End Sub
</script>
<head>
<title>Details</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body vlink="#990000">
<asp:Label ID="Header" runat="server" Font-Size="18 pt" Font-Bold="true" />
<br>
<br>
<aspataGrid ID="AdsGrid" runat="server" AutoGenerateColumns="false"
Border="1" BackColor="#FFFF00" Width="100%" BorderColor="#000000" CellSpacing="0" CellPadding="5">
<columns>
<asp:BoundColumn
HeaderText="Title"
datafield="Title">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Price"
datafield="Price">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="State"
datafield="State">
</asp:BoundColumn>
</columns>
</aspataGrid>
<br>
<center>
<asp:HyperLink ID="HomeLink" runat="server" NavigateUrl="default.aspx" Font-Bold="true" Font-Name="verdana" Font-Size="12 pt">
[ Home ]
</asp:HyperLink>
</center>
</body>
</html>