ASP.NET Gridview the server tag is not well formed

12,827

Solution 1

The words Server and Text need a space between them in the tag. Actually, most of the tag needs spacing added between the elements. So try this tag instead, note I've added some spaces between elements within the tag.

<asp:TextBox ID="textbox1" runat="server" Text='<%#Eval("lastname")%>'>

Solution 2

I faced the same error.. the server tag is not well formed

But i gave like this

<asp:TextBox ID="textbox1" runat="server" Text="<%#Eval("lastname")%>"></asp:TextBox>

Instead of

<asp:TextBox ID="textbox1" runat="server" Text='<%#Eval("lastname")%>'></asp:TextBox>

If give a text with in Double Quote it will give error like this

Share:
12,827
user2508738
Author by

user2508738

Updated on June 04, 2022

Comments

  • user2508738
    user2508738 about 2 years

    I'm trying to make my GridView editable, which will be filled with data from the database.

    When my program starts, it will connect to the database and fill the GridView with data. Now I want to edit the data in it, but when I start my program, I get the error "the server tag is not well formed."

    Of course I'm looking for some solutions and the most common mistake was, that "" was used instead of '', but I'm already using ''.

    Here is my code:

    <asp:GridView ID="griddb" runat="server" AutoGenerateEditButton="True" 
    CellPadding="4" EnableModelValidation="True" ForeColor="#333333" 
    GridLines="None">
    <AlternatingRowStyle BackColor="White" />
    <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
    <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
    <Columns>
    
    <asp:TemplateField HeaderText="Name" ><ItemTemplate>
    <%#Eval("lastname")%></ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="textbox1"runat="server"Text='<%#Eval("lastname")%>'>
    </asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateField>
    
    </Columns>
    </asp:GridView>
    

    The following snippet is marked as the error:

    <asp:TextBox ID="textbox1"runat="server"Text='<%#Eval("lastname")%>'>
    

    Thanks in advance.

  • Harsh Vyas
    Harsh Vyas about 4 years
    :D thanks man you saved my whole day. I mean it could be this stupid, single quote instead of double :D