Link to home
Start Free TrialLog in
Avatar of chrisgreaves
chrisgreavesFlag for Canada

asked on

Primary key insert in a Detailsview control.

Hello,
I'm using a Detailsveiew control for adding a new contact to tbl_contacts. The control is bound to a class in the middle tier...clscontacts.
I need to take a new primary key from a table of lastkeysused and use it for the new contact being entered in the Detailsview. I can retrieve the new key...but I cannot get it into the detailsview row so it can be included in the INSERT.
Can it be done? or am I taking the wrong approach?
Thanks.\Chris
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            'Get the next key for this insert
            Dim mylist As List(Of clslastkey)
            Dim myclslastkey As clslastkey
            mylist = LastKeyDAL.GetLastKey() 'get the list...just 1 record in this case
            myclslastkey = mylist(0) ' get the first item in the list
            lblnextcontactID.Text = myclslastkey.nextcontactID 'get the next key        
 
 
 
 
 
        End If
 
    End Sub

Open in new window

SOLUTION
Avatar of mildurait
mildurait
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial