|
-
Dec 11th, 2003, 09:32 PM
#1
Thread Starter
PowerPoster
Please help with optimizing.
Ok, this might be a simple question, but I have been taking a datarow that holds all the information for the page's controls and populating one control at a time. This is so inefficient, and I am wondering what you do.
With a Win Form app, I set the controls tag properties to the column name that the control gets populated with. This allows me to run each control through a loop to find its own data and populate itself. Then I just do a for each loop looping the controls through the procedure to match up the data. Obviously Web Apps don't have the tag, and the control collections seem to also be a little more complex than what I have encountered on a windows app.
Any suggestions?
Here is some sample code I use on each page to fill the controls:
Code:
Private Sub BindPoleDetails()
Dim dtPoleData As New DataTable
Dim boPole As New BOPole
Dim intID As Integer
Try
'Check for a querystring ID
intID = CType(Request.QueryString.Item("PoleID"), Integer)
dtPoleData = boPole.GetPole(intID)
'TODO:Extend the textbox to add tags.
If Not dtPoleData Is Nothing Then
If Not dtPoleData.Rows(0)("WO #") Is DBNull.Value Then
txtWorkOrderNum.Text = dtPoleData.Rows(0)("WO #")
End If
If Not dtPoleData.Rows(0)("Class") Is DBNull.Value Then
txtClass.Text = dtPoleData.Rows(0)("Class")
End If
If Not dtPoleData.Rows(0)("TRS") Is DBNull.Value Then
txtTownship.Text = dtPoleData.Rows(0)("TRS")
End If
If Not dtPoleData.Rows(0)("Service Address") Is DBNull.Value Then
txtServiceAddress.Text = dtPoleData.Rows(0)("Service Address")
End If
If Not dtPoleData.Rows(0)("Comments") Is DBNull.Value Then
txtComments.Text = dtPoleData.Rows(0)("Comments")
End If
If Not dtPoleData.Rows(0)("Install Date") Is DBNull.Value Then
txtInstallDate.Text = dtPoleData.Rows(0)("Install Date")
End If
If Not dtPoleData.Rows(0)("Mfr date") Is DBNull.Value Then
txtManufactureDate.Text = dtPoleData.Rows(0)("Mfr date")
End If
If Not dtPoleData.Rows(0)("Size") Is DBNull.Value Then
ddlSize.SelectedValue = dtPoleData.Rows(0)("Size")
End If
If Not dtPoleData.Rows(0)("Owner") Is DBNull.Value Then
ddlOwner.SelectedValue = dtPoleData.Rows(0)("Owner")
End If
If Not dtPoleData.Rows(0)("Mfr") Is DBNull.Value Then
ddlManufacturer.SelectedValue = dtPoleData.Rows(0)("Mfr")
End If
If Not dtPoleData.Rows(0)("Location") Is DBNull.Value Then
ddlCounty.SelectedValue = dtPoleData.Rows(0)("Location")
End If
If Not dtPoleData.Rows(0)("Type") Is DBNull.Value Then
ddlOwnerType.SelectedValue = dtPoleData.Rows(0)("Type")
End If
If Not dtPoleData.Rows(0)("InActive") Is DBNull.Value Then
cbInActive.Checked = dtPoleData.Rows(0)("InActive")
End If
If Not dtPoleData.Rows(0)("Rotten") Is DBNull.Value Then
chbRotten.Checked = dtPoleData.Rows(0)("Rotten")
End If
If Not dtPoleData.Rows(0)("RetireWO") Is DBNull.Value Then
txtRetireWONum.Text = dtPoleData.Rows(0)("RetireWO")
End If
If Not dtPoleData.Rows(0)("RetireDate") Is DBNull.Value Then
txtRetireDate.Text = dtPoleData.Rows(0)("RetireDate")
End If
If Not dtPoleData.Rows(0)("SequenceNumber") Is DBNull.Value Then
txtSequenceNumber.Text = dtPoleData.Rows(0)("SequenceNumber")
End If
End If
Catch ex As Exception
'No PoleID in the query string. Send user to the home page.
Response.Redirect("default.aspx")
End Try
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|