Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7688609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:57:39+00:00 2026-05-31T19:57:39+00:00

My question is too simple but puzziling. i have a develop a mvc pages

  • 0

My question is too simple but puzziling. i have a develop a mvc pages to learn. i used Repeater server control.


<asp:Repeater ID="ProductList" runat="server">
<ItemTemplate>
<li>
<%#Eval("Name") %>
</li>
</ItemTemplate>

also : (VIEW)

public partial class ListProduct : ViewPage
{
   protected void Page_Load(object sender, EventArgs e)
   {

                ProductList.DataSource = ViewData["Products"];
                ProductList.DataBind();
   }
}

My Repeater Server control is working good. BUT i’ve added a GridView control. An Error returns me :


<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
    <Columns>
    <asp:BoundField DataField="id" HeaderText="" Visible="false" />
    <asp:BoundField DataField="Name" HeaderText="" Visible="true" />

    </Columns>
    </asp:GridView>

<asp:Repeater ID="ProductList" runat="server">
<ItemTemplate>
<li>
<%#Eval("Name") %>
</li>
</ItemTemplate>
</asp:Repeater>

</asp:Content>

VIEW:



            GridView1.DataSource = ViewData["Products"];
            GridView1.DataBind();

Error**: Control ‘ContentPlaceHolder2_GridView1’ of type ‘GridView’ must be placed inside a form tag with runat=server.**

i understood and solved probblem by adding form runat server. But i dont understand REASON? Repeater and GridView are Server control. There is no error repeater in only repeater usage. GRidView return error. Why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:57:40+00:00Added an answer on May 31, 2026 at 7:57 pm

    What are you doing? Server side controls in an ASP.NET MVC application? Please don’t. Stop this madness.

    No.

    The Repeater might work as it doesn’t depend on ViewState but GridView -> forget about that. Also forget about Repeater. Also forget about anything that has runat="server" in an ASP.NET MVC application (except the content placeholders if you are using the WebForms view engine).

    In ASP.NET MVC you could use the WebGrid helper to render a grid. And you could replace your Repeater with Editor or Display templates.

    There really is no point of doing ASP.NET MVC if you need to use GridViews and stuff like that. Use a classic WebForm for this purpose.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

may be too simple groovy question but....please help i have a list like this:
this is probably too simple of a question, but here I go. I have
I'm new to asp.net mvc, so excuse me if my question is too simple.
i hope this question is not too simple, but i have no idea :(
Well looks too simple a question to be asked but i asked after going
This is a very simple, probably too simple question but I'm afraid my limited
The question is too simple, but still appreciate the short answer. I would like
Maybe this is a too simple question but I'm kind of stuck here. I've
The question might seem too simple or might be irrelevant here. But i need
Okay this may seem too simple of a question but I've wasted enough time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.