Enter Text into Detailsview on Insert.
-
Hi All I have a detailsview in Insert Mode and want to populate the myID field on insert with a new index number. What I am doing is checking the last index number and adding 1. Then I want to put this value in to the Detailsview myID field in read only so users can not change it. I want this to happen on the Detailsview_Inserting event. See code below....
Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles DetailsView1.ItemInserted If DetailsView1.CurrentMode = FormViewMode.Insert Then LoadData() 'Get max entry in table myID field. 'Increment by one. 'Add to the myID field in the dateview. End If End Sub Private Sub LoadData() Dim oleConn As New OleDbConnection oleConn.ConnectionString = ConfigurationManager.ConnectionStrings("ShowRegDBConnectionString").ConnectionString Dim oleComm As New OleDb.OleDbCommand oleComm.Connection = oleConn Try oleConn.Open() oleComm.CommandText = ("SELECT Max(myID) FROM SuggestionTB") Dim myID As String = Convert.ToString(oleComm.ExecuteScalar()) oleConn.Close() LastValue = myID Catch ex As OleDbException oleConn.Close() End Try End Sub
Any ideas....When people make you see red, be thankful your not colour blind.