Question

I Want to bind detailsview to the page manually , for example

I Have a linqdatasource as declared here in design mode..

On a page load event I have written following..

protected void Page_Load(object sender, EventArgs e)
{
    DetailsView dv = new DetailsView();
    dv.AllowPaging = true;
    dv.DataSource = LinqDataSource1;
    dv.DataBind();
    this.Controls.Add(dv);
}

but i got error like this..

Control 'ctl02' of type 'DetailsView' must be placed inside a form tag with runat=server.

Was it helpful?

Solution

Add a placeholder inside the form in ASPX and add your detailsview to the placeholder from code behind.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top