Server Error -- please help!

M

momo

Hello Guys,

I am getting this error "
Control 'oGrid__ctl14__ctl1' of type 'DataGridLinkButton' must be placed
inside a form tag with runat=server."


Here is my code and I don't know where it is doing it. Can some please help
me


<%@ Page language="VB" Debug="false" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>


<script language="VB" runat="server">



Sub Page_Load(Sender as Object, E as EventArgs)
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
Dim oConn As OleDbConnection
Dim oComm As OleDbDataAdapter
Dim sConn As String
Dim sComm As String
Dim oDataSet As New DataSet
dim Pathdb as String
Pathdb = String.Format(server.mappath("reports/db/specialk.mdb"))
'Build the connection string
'sConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
'sConn += "Data Source=" & server.mappath("reports/db/specialk.mdb") & ";"
' sConn += "Persist Security Info=False"

'Build the SQL string sComm = "SELECT Products.ProductID, "
'sComm += "Products.ProductName, "
'sComm += "Products.ProductDescription, "
'sComm += "Products.UnitPrice "
sComm += "Select LastName, FirstName, Phone FROM tblEmployeeChecklist
where ActiveStatus=Yes order by lastname"' & "'"

'Usually you would use error-handling here. It is left out to
'make the code as simple as possible.
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
Try
'Create the connection and command objects
oConn = GetMsAccessOledbConnection(Pathdb, "admin", "")
'oConn = New OleDbConnection(sConn)

oComm = New OleDbDataAdapter(sComm, oConn)
'Fill the dataset with the results of the query
oComm.Fill(oDataSet, "Employees")

'Set the grid source to the dataset and bind the data
oGrid.DataSource=oDataSet.Tables("Employees").DefaultView
oGrid.DataBind()
Catch ex As Exception
'if there is a database error, it will get caught here
oDataSet = Nothing
Response.Write ("An Error Occurred: " & ex.toString())
Finally
'Ensure that the objects are disposed
oComm.Dispose()
oConn.Dispose()
End Try
End Sub
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
public shared function GetMsAccessOledbConnection(ByVal dbPath As String,
ByVal dbID As String, ByVal dbPassword As String)
Dim dbConn As OleDbConnection
Dim dbConnStr As String =
String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};User
ID={1};Password={2}", dbPath, dbID, dbPassword)
return new OleDbConnection(dbConnStr)
End function
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
sub dgEmployee_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)
if e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='orange'")
End if
if e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='Beige'")
else if e.Item.ItemType = ListItemType.header Or e.Item.ItemType =
ListItemType.footer Then
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='#aaaadd'")
else
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='Burlywood'")
End if
End sub
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'
Sub oGrid_Page(sender As Object, e As DataGridPageChangedEventArgs)
oGrid.CurrentPageIndex = e.NewPageIndex
BindGrid
End Sub

Sub BindGrid()
'oGrid.DataSource = oDataSet.Tables("Employees").DefaultView
oGrid.DataBind()
End Sub

</script>

<html>
<head>
<title>Fill A DataGrid From Access Database</title>
</head>
<body>


<asp:DataGrid
ID="oGrid"
runat="server"
autogeneratecolumns="false"
OnItemDataBound="dgEmployee_ItemDataBound"
BorderColor="black"
CellPadding="2"
CellSpacing="0"
Font-Size="10pt"
ForeColor="Black"
BackColor="Beige"
ShowHeader="True"
ShowFooter="True"
AlternatingItemStyle-ForeColor="Black"
AlternatingItemStyle-Font-Name="Arial"
AlternatingItemStyle-Font-bold="True"
AlternatingItemStyle-BackColor="Burlywood"
AlternatingItemStyle-Font-Size="10"

HeaderStyle-Font-Bold="True"
FooterStyle-BackColor="#9B0000"
FooterStyle-Font-Bold="True"
Headerstyle-BackColor="#9B0000"
Headerstyle-Forecolor="#FFFFFF"
Headerstyle-Font-Name="Arial"
Headerstyle-Font-Size="11"
Font-Name="Arial"

AllowPaging="True"
PageSize="10"
PagerStyle-Mode="NumericPages"
PagerStyle-HorizontalAlign="Right"
PagerStyle-NextPageText="Next"
PagerStyle-PrevPageText="Prev"
OnPageIndexChanged="oGrid_Page"
<Columns>
<asp:templatecolumn headertext="#">
<itemtemplate> <span><%# Container.ItemIndex+1 %></span>
</itemtemplate>
</asp:templatecolumn>
<asp:TemplateColumn HeaderText="Last Name"
HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblLastName" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "LastName") %>'/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="First Name"
HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblfirstName" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "firstName") %>'/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Phone#"
HeaderStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblPhone" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Phone") %>'/>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</body>
</html>
 
G

Gozirra

You have no form tag. ASP Controls are required to be inside of single
form tag. As in
<body>
<form id="Form1" method="post" runat="server">
All your controls here.
</form>
</body>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top