I have set up a page with a gridview and formview to show the details. All this information is pulled from SQL 2005 tables. What I am wanting to do is on Formview_ModeChanged and Formview.CurrentMode = EditMode then I want it to pull updated values from
an Oracle table. Basically the user selects a record from the gridview and then sees the details in the formview section. Once they click on the Edit button on the Formview some of the data is bounced off of the Oracle database in order to pull the latest
values (for example updating the latest employee information from a central database into my database). Then the user can make any changes to the record and ALL updates are sent to the SQL 2005 database. I had some script that did this in ASP.NET 1.1 but in
2.0 every data source is linked to some databound control. Is there any way to do this like in ASP.NET 1.1 or even an easier way?
Wow. Nobody has any ideas or can provide any help on this?
In ASP.NET 1.1 I used a datareader to pull all the values. In .NET 2.0 there isn't a direct way to do this. That I know of anyways. Any help would be greatly appreciated.
Can you post an example of the code that you are using in 1.1? It's too early in the morning for me to conceptualize what the problem is, but there's no reason why you can't dynamically bind data from a datareader into a gridview/form whatever in 2.0.
Well here's the problem. I already have a gridview/formview set up with their sql datasources. My only problem is that once the user clicks on the edit button I want it to pull data from the Oracle table. All I'm doing is refreshing the employee information
with data from our central database. Here's the code on how I did it in 1.1:
Sub EditForm(sender As Object, e As System.EventArgs)
cmbCallStatus.Enabled = "True"
cmbCallerType.Enabled = "True"
txtCallerEmployeeID.Enabled = "True"
txtCallerPhone1.Enabled = "True"
txtCallerPhone2.Enabled = "True"
cmbMajBusFunctionArea.Enabled = "True"
cmbCompetitiveHireInfo.Enabled = "True"
txtHROMNotes.Enabled = "True"
btnEdit.Enabled = "False"
btnUpdate.Enabled = "True"
'Reload EV2 Employee Information
Dim strEE As String
Dim HireDate As Date
strEE = lblEmployeeID.Text
Dim oOracleConn As OracleConnection = New OracleConnection()
Dim dataReader As OracleClient.OracleDataReader
oOracleConn.ConnectionString = "Data Source=test;User Id=test;Password=test;Integrated Security=no;"
Dim myInsertQuery As String = "SELECT * FROM myOracleView WHERE EMPLOYEE_NUMBER='" & strEE & "'"
Dim myOracleCommand As New OracleCommand(myInsertQuery)
myOracleCommand.Connection = oOracleConn
oOracleConn.Open()
dataReader = myOracleCommand.ExecuteReader()
If dataReader.Read() = True Then
lblEmployeeLastName.text=dataReader("EMPLOYEE_LAST_NAME").ToString()
lblEmployeeFirstName.text=dataReader("EMPLOYEE_FIRST_NAME").ToString()
lblMgrEmployeeID.text=dataReader("SUPERVISOR_ID").ToString()
lblMgrLastName.text=dataReader("MANAGER_LAST_NAME").ToString()
lblMgrFirstName.text=dataReader("MANAGER_FIRST_NAME").ToString()
lblOrgCode.text=dataReader("DEPARTMENT").ToString()
lblOrgName.text=dataReader("DEPARTMENT_DESCRIPTION").ToString()
lblWorkLocationCity.Text=dataReader("WORK_LOCATION_CITY").ToString()
lblWorkLocationState.Text=dataReader("WORK_LOCATION_STATE").ToString()
lblAge.Text=dataReader("AGE")
lblDOB.Text=dataReader("BIRTHDATE")
lblEmployeeStatusCode.Text=dataReader("XE_STATUS_CD").ToString()
lblEmployeeStatusDesc.Text=dataReader("STATUS_DESCR").ToString()
lblEmployeeStatusEffDate.Text=FormatDateTime(dataReader("XE_ST_ENTRY_DT"), DateFormat.ShortDate)
lblJobCode.Text=dataReader("JOBCODE")
lblJobTitle.text=dataReader("JOB_DESCRIPTION").ToString()
HireDate=dataReader("ORIGINAL_HIRE_DT")
lblHireDate.text=HireDate.ToString("d")
lblYrsOfService.Text=dataReader("SERVICE_YEARS")
Select Case dataReader("ETHNIC_GRP_CODE").ToString()
Case "1"
lblEEO.text=("1 - White (Not of Hispanic Origin)")
Case "2"
lblEEO.text=("2 - Black (Not of Hispanic Origin)")
Case "3"
lblEEO.text=("3 - Hispanic")
Case "4"
lblEEO.text=("4 - Asian or Pacific Islander")
Case "5"
lblEEO.text=("5 - American Indian / Alaskan Native")
Case Else
End Select
Select Case dataReader("SEX_CODE").ToString()
Case "F"
lblGender.text=("Female")
Case "M"
lblGender.text=("Male")
Case Else
End Select
Select Case dataReader("EDUCATION_CD").ToString()
Case "1"
lblEducation.text=("Associates")
Case "2"
lblEducation.text=("Bachelors")
Case "3"
lblEducation.text=("Masters")
Case "4"
lblEducation.text=("Doctorate")
Case "A"
lblEducation.text=("1-2 Years")
Case "B"
lblEducation.text=("3-4 Years")
Case "C"
lblEducation.text=("Post Bach")
Case "D"
lblEducation.text=("Post Mast")
Case "E"
lblEducation.text=("Post Doct")
Case Else
End Select
Select Case dataReader("REFERRAL_SOURCE").ToString()
Case "AD"
lblReferralSource.text=("Advertisement")
Case "AG"
lblReferralSource.text=("N/A")
Case "AQ"
lblReferralSource.text=("Acquisition")
Case "CA"
lblReferralSource.text=("Career Center")
Case "CC"
lblReferralSource.text=("Contract Worker Conversion")
Case "CO"
lblReferralSource.text=("College Recruiting")
Case "CR"
lblReferralSource.text=("Corporate/Direct Recruiting")
Case "EA"
lblReferralSource.text=("Employment Agency")
Case "EE"
lblReferralSource.text=("Employee Referral")
Case "FE"
lblReferralSource.text=("Former Employee")
Case "IN"
lblReferralSource.text=("Internet Posting")
Case "JF"
lblReferralSource.text=("Job Fair")
Case "JP"
lblReferralSource.text=("Job Posting")
Case "OT"
lblReferralSource.text=("Other Source")
Case "US"
lblReferralSource.text=("Unsolicited")
Case "XR"
lblReferralSource.text=("Executive Referral")
Case "XS"
lblReferralSource.text=("Executive Search")
Case Else
End Select
dataReader.Close()
End If
oOracleConn.Close()
Now here's my other problem. I'm using the code above to populate the fields. The only difference is that now these fields are inside a tabcontainer, inside a tab, inside a formview control. When I try to use the formview.findcontrol method it simply cannot
find the control for some reason. I've ensure that I am doing this on the itemdatabound event so I know that the fields I'm searching for are the right ones.
Nevermind. I stepped/debug through the code and found out that my NullReferenceException was coming from my connection string not that it could not find the controls.
axeman420
Member
46 Points
52 Posts
How to programmatically set values in .NET 2.0
Feb 09, 2007 07:47 PM|LINK
Hello all,
I have set up a page with a gridview and formview to show the details. All this information is pulled from SQL 2005 tables. What I am wanting to do is on Formview_ModeChanged and Formview.CurrentMode = EditMode then I want it to pull updated values from an Oracle table. Basically the user selects a record from the gridview and then sees the details in the formview section. Once they click on the Edit button on the Formview some of the data is bounced off of the Oracle database in order to pull the latest values (for example updating the latest employee information from a central database into my database). Then the user can make any changes to the record and ALL updates are sent to the SQL 2005 database. I had some script that did this in ASP.NET 1.1 but in 2.0 every data source is linked to some databound control. Is there any way to do this like in ASP.NET 1.1 or even an easier way?
Thanks in advance,
axeman420
Member
46 Points
52 Posts
Re: How to programmatically set values in .NET 2.0
Feb 11, 2007 08:38 PM|LINK
Wow. Nobody has any ideas or can provide any help on this?
In ASP.NET 1.1 I used a datareader to pull all the values. In .NET 2.0 there isn't a direct way to do this. That I know of anyways. Any help would be greatly appreciated.
Thanks in advance,
Axe
Mr^B
Star
12726 Points
2245 Posts
Re: How to programmatically set values in .NET 2.0
Feb 12, 2007 08:13 AM|LINK
Hi,
Can you post an example of the code that you are using in 1.1? It's too early in the morning for me to conceptualize what the problem is, but there's no reason why you can't dynamically bind data from a datareader into a gridview/form whatever in 2.0.
axeman420
Member
46 Points
52 Posts
Re: How to programmatically set values in .NET 2.0
Feb 12, 2007 12:22 PM|LINK
Well here's the problem. I already have a gridview/formview set up with their sql datasources. My only problem is that once the user clicks on the edit button I want it to pull data from the Oracle table. All I'm doing is refreshing the employee information with data from our central database. Here's the code on how I did it in 1.1:
Sub EditForm(sender As Object, e As System.EventArgs)
cmbCallStatus.Enabled = "True"
cmbCallerType.Enabled = "True"
txtCallerEmployeeID.Enabled = "True"
txtCallerPhone1.Enabled = "True"
txtCallerPhone2.Enabled = "True"
cmbMajBusFunctionArea.Enabled = "True"
cmbCompetitiveHireInfo.Enabled = "True"
txtHROMNotes.Enabled = "True"
btnEdit.Enabled = "False"
btnUpdate.Enabled = "True"
'Reload EV2 Employee Information
Dim strEE As String
Dim HireDate As Date
strEE = lblEmployeeID.Text
Dim oOracleConn As OracleConnection = New OracleConnection()
Dim dataReader As OracleClient.OracleDataReader
oOracleConn.ConnectionString = "Data Source=test;User Id=test;Password=test;Integrated Security=no;"
Dim myInsertQuery As String = "SELECT * FROM myOracleView WHERE EMPLOYEE_NUMBER='" & strEE & "'"
Dim myOracleCommand As New OracleCommand(myInsertQuery)
myOracleCommand.Connection = oOracleConn
oOracleConn.Open()
dataReader = myOracleCommand.ExecuteReader()
If dataReader.Read() = True Then
lblEmployeeLastName.text=dataReader("EMPLOYEE_LAST_NAME").ToString()
lblEmployeeFirstName.text=dataReader("EMPLOYEE_FIRST_NAME").ToString()
lblMgrEmployeeID.text=dataReader("SUPERVISOR_ID").ToString()
lblMgrLastName.text=dataReader("MANAGER_LAST_NAME").ToString()
lblMgrFirstName.text=dataReader("MANAGER_FIRST_NAME").ToString()
lblOrgCode.text=dataReader("DEPARTMENT").ToString()
lblOrgName.text=dataReader("DEPARTMENT_DESCRIPTION").ToString()
lblWorkLocationCity.Text=dataReader("WORK_LOCATION_CITY").ToString()
lblWorkLocationState.Text=dataReader("WORK_LOCATION_STATE").ToString()
lblAge.Text=dataReader("AGE")
lblDOB.Text=dataReader("BIRTHDATE")
lblEmployeeStatusCode.Text=dataReader("XE_STATUS_CD").ToString()
lblEmployeeStatusDesc.Text=dataReader("STATUS_DESCR").ToString()
lblEmployeeStatusEffDate.Text=FormatDateTime(dataReader("XE_ST_ENTRY_DT"), DateFormat.ShortDate)
lblJobCode.Text=dataReader("JOBCODE")
lblJobTitle.text=dataReader("JOB_DESCRIPTION").ToString()
HireDate=dataReader("ORIGINAL_HIRE_DT")
lblHireDate.text=HireDate.ToString("d")
lblYrsOfService.Text=dataReader("SERVICE_YEARS")
Select Case dataReader("ETHNIC_GRP_CODE").ToString()
Case "1"
lblEEO.text=("1 - White (Not of Hispanic Origin)")
Case "2"
lblEEO.text=("2 - Black (Not of Hispanic Origin)")
Case "3"
lblEEO.text=("3 - Hispanic")
Case "4"
lblEEO.text=("4 - Asian or Pacific Islander")
Case "5"
lblEEO.text=("5 - American Indian / Alaskan Native")
Case Else
End Select
Select Case dataReader("SEX_CODE").ToString()
Case "F"
lblGender.text=("Female")
Case "M"
lblGender.text=("Male")
Case Else
End Select
Select Case dataReader("EDUCATION_CD").ToString()
Case "1"
lblEducation.text=("Associates")
Case "2"
lblEducation.text=("Bachelors")
Case "3"
lblEducation.text=("Masters")
Case "4"
lblEducation.text=("Doctorate")
Case "A"
lblEducation.text=("1-2 Years")
Case "B"
lblEducation.text=("3-4 Years")
Case "C"
lblEducation.text=("Post Bach")
Case "D"
lblEducation.text=("Post Mast")
Case "E"
lblEducation.text=("Post Doct")
Case Else
End Select
Select Case dataReader("REFERRAL_SOURCE").ToString()
Case "AD"
lblReferralSource.text=("Advertisement")
Case "AG"
lblReferralSource.text=("N/A")
Case "AQ"
lblReferralSource.text=("Acquisition")
Case "CA"
lblReferralSource.text=("Career Center")
Case "CC"
lblReferralSource.text=("Contract Worker Conversion")
Case "CO"
lblReferralSource.text=("College Recruiting")
Case "CR"
lblReferralSource.text=("Corporate/Direct Recruiting")
Case "EA"
lblReferralSource.text=("Employment Agency")
Case "EE"
lblReferralSource.text=("Employee Referral")
Case "FE"
lblReferralSource.text=("Former Employee")
Case "IN"
lblReferralSource.text=("Internet Posting")
Case "JF"
lblReferralSource.text=("Job Fair")
Case "JP"
lblReferralSource.text=("Job Posting")
Case "OT"
lblReferralSource.text=("Other Source")
Case "US"
lblReferralSource.text=("Unsolicited")
Case "XR"
lblReferralSource.text=("Executive Referral")
Case "XS"
lblReferralSource.text=("Executive Search")
Case Else
End Select
dataReader.Close()
End If
oOracleConn.Close()
Page.Validate
End Sub
Mr^B
Star
12726 Points
2245 Posts
Re: How to programmatically set values in .NET 2.0
Feb 13, 2007 10:54 AM|LINK
axeman420
Member
46 Points
52 Posts
Re: How to programmatically set values in .NET 2.0
Feb 13, 2007 12:34 PM|LINK
Is there not a more efficient way of doing this in 2.0? Just wondering. I don't want to stick to old code if it can be done a better way.
Mr^B
Star
12726 Points
2245 Posts
Re: How to programmatically set values in .NET 2.0
Feb 13, 2007 02:07 PM|LINK
axeman420
Member
46 Points
52 Posts
Re: How to programmatically set values in .NET 2.0
Feb 13, 2007 02:12 PM|LINK
Now here's my other problem. I'm using the code above to populate the fields. The only difference is that now these fields are inside a tabcontainer, inside a tab, inside a formview control. When I try to use the formview.findcontrol method it simply cannot find the control for some reason. I've ensure that I am doing this on the itemdatabound event so I know that the fields I'm searching for are the right ones.
Any ideas?
Axe
axeman420
Member
46 Points
52 Posts
Re: How to programmatically set values in .NET 2.0
Feb 13, 2007 03:54 PM|LINK
Nevermind. I stepped/debug through the code and found out that my NullReferenceException was coming from my connection string not that it could not find the controls.
Thank you for your help!
Axe