views:

1008

answers:

2

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?

+2  A: 

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

David HAust
I'm doing this same thing. To help expand on it, i'm passing in a QueryString param and if it's set, then I'll perform the ChangeMode on the page_load.ex: /mypage.aspx?edit=true
Dave
+1  A: 

I just wanted to follow up and say that, even though I did not find a way to link to a specific page state, I did discover the dataview's DefaultMode parameter, that at least allows you to pick an initial state.

Thus: DefaultMode="Insert"

At least lets you choose insert mode as the default.

danieltalsky