Search code examples
asp.netweb-applicationsasp.net-2.0detailsview

How do I link to an ASP:DetailsView's Insert mode via an external page


Unlike many of the ASP.NET documentation and examples, I'm doing a gridview list on one page, and it links to a 2nd page to do the edit/update view, sending the ID for the record in the GET string.

On my edit/update view, I'm using an ASP:DetailsView for viewing, editing and inserting records. All of this works fine.

On the detailsView page, I have it autogenerating a new record link that uses postback to show the blank insert form to be filled out.

The only problem is, I have no idea how to link to the insert view of the DetailsView from an external page. Am I missing something?


Solution

  • I could have misunderstood your question but....

    I don't believe you can 'link to the insert view', but what you can do is programmatically change the mode of the DetailsView once the page has loaded. Remember to check that the passed in ID has a value first.

    For example:

    If Not idValue Is Nothing Then   
        yourDetailsViewName.ChangeMode(DetailsViewMode.Insert)
    End If
    

    Check out the MSDN page for more info:
    DetailsView.ChangeMode Method