Click here to Skip to main content
16,015,679 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: control position problem in VS2008 IDE? Pin
Dr.Walt Fair, PE14-Nov-10 12:25
professionalDr.Walt Fair, PE14-Nov-10 12:25 
AnswerRe: control position problem in VS2008 IDE? Pin
praveen_gpk15-Nov-10 19:21
praveen_gpk15-Nov-10 19:21 
QuestionDIV position problem generated dynamically from javascript Pin
Tridip Bhattacharjee14-Nov-10 0:24
professionalTridip Bhattacharjee14-Nov-10 0:24 
Questionhow to position div just over the textbox? Pin
Tridip Bhattacharjee13-Nov-10 20:30
professionalTridip Bhattacharjee13-Nov-10 20:30 
AnswerRe: how to position div just over the textbox? Pin
Brij13-Nov-10 22:22
mentorBrij13-Nov-10 22:22 
GeneralRe: how to position div just over the textbox? Pin
Tridip Bhattacharjee13-Nov-10 22:49
professionalTridip Bhattacharjee13-Nov-10 22:49 
GeneralRe: how to position div just over the textbox? Pin
Brij13-Nov-10 23:52
mentorBrij13-Nov-10 23:52 
QuestionHow to pass data to gridview(Long Post) Pin
future383913-Nov-10 13:46
future383913-Nov-10 13:46 
Hi, every one. I am new in MVC and just practicing to improve my knowledge.I have the following codes and trying to pass data to GridView. but I get error after running the page.



Its my PersonController
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using MvcApplication1.ViewModels;
using MvcApplication1.Models;

namespace MvcApplication1.Controllers
{
    public class PersonController : Controller
    {
        HostelEntities1 HostelDB = new HostelEntities1();
        //
        // GET: /Person/

        public ActionResult Index()
        {
           var Persons = from peson in HostelDB.Person_prs
                        select peson.fname_prs;
           var ViewModel = new PersonIndexViewModel
           {
               Person = Persons.ToList(),
               NumberOfPeople= Persons.Count()
           };
            return View(ViewModel);
        }
    }
}


Its my ViewModel Class. I have class called PersonIndexViewModel
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MvcApplication1.ViewModels
{
    public class PersonIndexViewModel
    {
        public int NumberOfPeople { set; get; }
        public List<string> Person { set; get; }
    }
}



and finally in View folder I have the following code
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.ViewModels.PersonIndexViewModel>" %>

<%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>
<script type="text/C#" runat=server>
    protected void Page_Load(object sender, EventArgs e)
    {
        this.GridView1.DataSource = this.Model.Person;
        this.GridView1.DataBind();
    }

</script>


<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>This Page List Name Of People</h2>
    
    <p>select from<%=Model.NumberOfPeople%></p>
    <ul>
        <%foreach (string NamePeople in Model.Person)
          { %>
        <li>
            <%=NamePeople%>
        </li>
        <%} %>
    </ul>
    <asp:GridView ID="GridView1" runat="server" Width="50%" EnableViewState="False" 
        DataSourceID="EntityDataSource1">
    </asp:GridView>
    
    <asp:EntityDataSource ID="EntityDataSource1" runat="server">
    </asp:EntityDataSource>
     
</asp:Content>

after running I face with this error
<br />
Control 'ctl00_MainContent_GridView1' of type 'GridView' must be placed inside a form tag with runat=server.<br />


Could yo please help me out.
modified on Sunday, November 14, 2010 8:15 AM

AnswerRe: How to pass data to gridview(Long Post) Pin
thatraja15-Nov-10 1:47
professionalthatraja15-Nov-10 1:47 
QuestionWhat is best way to show Grid inside a TabPanel Pin
Steve van Niman13-Nov-10 11:26
Steve van Niman13-Nov-10 11:26 
QuestionHost Web Service and Web Site in virtual directory & app pool Pin
kakarato13-Nov-10 5:06
kakarato13-Nov-10 5:06 
AnswerRe: Host Web Service and Web Site in virtual directory & app pool Pin
Brij13-Nov-10 7:14
mentorBrij13-Nov-10 7:14 
Questionmultiple getJSON issue [modified] Pin
musefan12-Nov-10 5:28
musefan12-Nov-10 5:28 
QuestionFail to avoid postback for button click Pin
Tridip Bhattacharjee11-Nov-10 23:01
professionalTridip Bhattacharjee11-Nov-10 23:01 
AnswerRe: Fail to avoid postback for button click Pin
Brij12-Nov-10 1:12
mentorBrij12-Nov-10 1:12 
GeneralRe: Fail to avoid postback for button click Pin
Tridip Bhattacharjee12-Nov-10 2:00
professionalTridip Bhattacharjee12-Nov-10 2:00 
GeneralRe: Fail to avoid postback for button click Pin
Brij12-Nov-10 6:38
mentorBrij12-Nov-10 6:38 
QuestionShowing content pages without MasterPage in DesignView. Pin
Asif Rehman11-Nov-10 4:03
Asif Rehman11-Nov-10 4:03 
AnswerRe: Showing content pages without MasterPage in DesignView. Pin
Brij11-Nov-10 6:32
mentorBrij11-Nov-10 6:32 
AnswerRe: Showing content pages without MasterPage in DesignView. Pin
Vimalsoft(Pty) Ltd14-Nov-10 20:03
professionalVimalsoft(Pty) Ltd14-Nov-10 20:03 
QuestionDetailsView FormView - SelectedValue bug Pin
Hanzaplast11-Nov-10 3:10
Hanzaplast11-Nov-10 3:10 
QuestionNavigating from a page to Wizrd page Pin
meeram39511-Nov-10 2:47
meeram39511-Nov-10 2:47 
AnswerRe: Navigating from a page to Wizrd page Pin
Not Active11-Nov-10 3:10
mentorNot Active11-Nov-10 3:10 
GeneralRe: Navigating from a page to Wizrd page Pin
meeram39511-Nov-10 12:30
meeram39511-Nov-10 12:30 
GeneralRe: Navigating from a page to Wizrd page Pin
Not Active11-Nov-10 12:46
mentorNot Active11-Nov-10 12:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.