Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 25th, 2005, 07:22 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default "The server tag is not well formed" Newbie...

I have been tearing my hair out for the last few days trying to get this example to work
Code:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="EventDrivenGrid.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
        <title>WebForm1</title>
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
            <asp:DataGrid
         id="dgCustomers"
         runat="server"
         Font-Size="8pt"
        Width="466px" Height="278px"
        HeaderStyle-BackColor="Yellow"
        BorderWidth="5"
        BorderColor="000099"
        AlternatingItemStyle-BackColor="LightGrey"
        AutoGenerateColumns="False"
            <Columns>
                    <asp:BoundColumn HeaderText="Company Name" DataField="CompanyName" />
                    <asp:BoundColumn HeaderText="Contact" DataField="ContactName" />
                    <asp:BoundColumn HeaderText="Title" DataField="ContactTitle" />
                    <asp:BoundColumn HeaderText="Phone" DataField="Phone" />
                </Columns>
        </asp:DataGrid>
        </form>
    </body>
</HTML>


with some c# behind

Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace EventDrivenGrid
{
    /// <summary>
    /// Summary description for WebForm1.
    /// </summary>
    public class WebForm1 : System.Web.UI.Page
    {
        protected System.Web.UI.WebControls.DataGrid DataGrid1;

        private void Page_Load(object Source, System.EventArgs E)
        {
            if(!IsPostBack)
            {
                // Create Connection String
                string strConnection =
                    "server=****; uid=sa; pwd=*********; database=northwind";
                //Create the command String
                string strCommand = "Select * from Customers";
                //Create the data set command object and dataset
                SqlDataAdapter dataAdapter =
                    new SqlDataAdapter(strCommand, strConnection);
                DataSet dataSet = new DataSet();
                //Fill the data set
                dataAdapter.Fill(dataSet,"Products");
                SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter);

                //Get the table
                DataTable datatable = dataSet.Tables[0];
                dgCustomers.dataSource = dataTable;
                dgCustomers.dataBind();
            }

        }

HOWEVER i keep getting the error

"The server tag is not well formed" refering to line 13
Code:
<asp:DataGrid
         id="dgCustomers"
         runat="server"


Meaning the c# cant fing the dgCustomers!

Can anyone help, i need to move on with this!!!

Thanks for any help offered

 
Old November 26th, 2005, 02:05 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

you need the end tag for your bound columns:
</asp:BoundColumn>

 
Old November 26th, 2005, 08:23 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, i can see why that wouldnt work, so i went with
Code:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="EventDrivenGrid.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
        <title>WebForm1</title>
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  </HEAD>
    <body>
    <form id="Form1" method="post" runat="server">
        <asp:DataGrid
                id="dgCustomers" 
                runat="server"
        Width="466px" Height="278px"
        HeaderStyle-BackColor="Yellow" 
        BorderWidth="5"
        BorderColor="000099"
        AlternatingItemStyle-BackColor="LightGrey"
        AutoGenerateColumns="False"

            <Columns >
            <asp:BoundColumn HeaderText ="Company Name" DataField = "CompanyName" />
            <asp:BoundColumn HeaderText = "Contact" DataField = "ContactName" />
            <asp:BoundColumn HeaderText = "Title" DataField = "ContactTitle" />
            <asp:BoundColumn HeaderText = "Phone" DataField = "Phone" />
            </asp:BoundColumn>
            </Columns>
            </asp:DataGrid>
         </form>
    </body>
</HTML>
and get exactly the same error

Quote:
quote:
"The server tag is not well formed" refering to line 13

<asp:DataGrid
         id="dgCustomers"
         runat="server"
Now i'm really confused!
ARRRGHHH!

 
Old November 27th, 2005, 02:27 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You need the closing </asp:BoundColumn> after EACH bound column.

Would be easier for VS to create the grid for you instead of trying to manually create the markup.


 
Old December 21st, 2007, 10:37 AM
Registered User
 
Join Date: Jun 2003
Location: Lubbock, Texas, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know that this is old, but the <asp:DataGrid> did not have a closing ">" after the AutoGenerateColumns="False".

Christopher Reed
Application Analyst
Web Development Coordinator
Information Technology
"...efficient operations and utilization of
                technology and communications..."
City of Lubbock
creed@mail.ci.lubbock.tx.us
"The oxen are slow, but the earth is patient."
 
Old June 6th, 2008, 10:54 AM
Registered User
 
Join Date: Jun 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

    <asp:DataGrid ID="dgCustomers" runat="server" Font-Size="8pt" Width="466px" Height="278px"
        HeaderStyle-BackColor="Yellow" BorderWidth="5" BorderColor="000099" AlternatingItemStyle-BackColor="LightGrey"
        AutoGenerateColumns="False">
        <Columns>
            <asp:BoundColumn HeaderText="Company Name" DataField="CompanyName" />
            <asp:BoundColumn HeaderText="Contact" DataField="ContactName" />
            <asp:BoundColumn HeaderText="Title" DataField="ContactTitle" />
            <asp:BoundColumn HeaderText="Phone" DataField="Phone" />
        </Columns>
    </asp:DataGrid>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Unknown Server Tag sharon5469 ASP.NET 1.0 and 1.1 Basics 3 June 18th, 2008 03:03 PM
XML That Is Not Well Formed rvanandel Ajax 3 July 2nd, 2007 11:46 AM
The server tag is not well formed. binici ASP.NET 2.0 Basics 6 May 15th, 2007 04:41 PM
Newbie experiencing probs with tag libs and frames rudi_doku JSP Basics 0 October 14th, 2003 10:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.