user2508738
user2508738

Reputation: 33

ASP.NET Gridview the server tag is not well formed

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.

Upvotes: 2

Views: 13856

Answers (2)

User6667769
User6667769

Reputation: 805

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

Upvotes: 6

Full Time Skeleton
Full Time Skeleton

Reputation: 1740

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")%>'>

Upvotes: 0

Related Questions