Hello,
I have a Contacts.aspx page that contains a SQLDataSource and a GridView control. The Contact_ID column in the GridView contains the following information in the hyperlink.
<a... NavigateUrl='<%# "~/Management/Forms/ContactEdit.aspx?ContactID=" & Eval("Contact ID") %>'.
This works fine and when the hyperlink is clicked, it sends the user to the ContactEdit.aspx page which has a SQLDataSource and a DetailsView control. on the ContactEdit.aspx.
vb page I have the following code to catch the incoming id value (the variable intContactID is declared above the Page_Load sub).
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Request.QueryString("ContactID") Is Nothing Or Request.QueryString("ContactID") = 0 Then
'Set detailsview into insert mode
ElseIf IsNumeric(Request.QueryString("ContactID")) Then
'Capture the incoming ContactId value
intContactID = Request.QueryString("ContactID")
Else
'Set to the DetailView to the first record in read mode
End If
End Sub
End Class
I still have code to write for the different scenarios but normally the ContactEdit.aspx page will be called with a valid contactid.
What I want to do is have the user browse the many contact records in the GridView (Contact.aspx) and if they want to edit a record they click on the Contact ID hyperlink associated with the particular record. Clicking the hyperlink will open the ContactEdit.aspx page which will have the record they had selected in the DetailsView control. What I haven't been able to figure out is how to open the DetailsView control with the ID that is being passed to the ContactEdit page. I know that I've captured the ID correctly because I can do a response.write(intContactID) on the page and it displays the contactid that I had sent from the previous page, but I don't know how to use the intContactID variable value to make it the record that is "loaded" or selected in the DetailsView control.
Any help would be greatly appreciated, thank you very much.