Click here to Skip to main content
16,005,491 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: reduce this big code Pin
Christian Graus25-Jul-07 18:50
protectorChristian Graus25-Jul-07 18:50 
GeneralRe: reduce this big code Pin
Brady Kelly25-Jul-07 23:23
Brady Kelly25-Jul-07 23:23 
GeneralRe: reduce this big code Pin
duo!@#26-Jul-07 15:22
duo!@#26-Jul-07 15:22 
GeneralRe: reduce this big code Pin
Brady Kelly26-Jul-07 20:23
Brady Kelly26-Jul-07 20:23 
GeneralRe: reduce this big code Pin
duo!@#26-Jul-07 20:45
duo!@#26-Jul-07 20:45 
GeneralRe: reduce this big code Pin
duo!@#26-Jul-07 15:25
duo!@#26-Jul-07 15:25 
AnswerRe: reduce this big code Pin
Sonia Gupta25-Jul-07 18:50
Sonia Gupta25-Jul-07 18:50 
AnswerRe: reduce this big code Pin
Brady Kelly27-Jul-07 3:56
Brady Kelly27-Jul-07 3:56 
1. Rename your label controls to reflect the lot they represent.1 So, instead of Label1, Label2, you have Label101Text, Label101Colour.
2. Group all selects into one query.
Dim sqlLotStatus As New Data.SqlClient.SqlCommand("select Lot_id, status from carpark where Lot_id between 101 and 304", conn1)
3. Loop through the result set and set properties on the appropriate labels:
Dim sqlDataReader As Data.SqlClient.SqlDataReader = sqlLotStatus.EndExecuteReader()

Dim lotStatus As String
Dim textLabelName As String
Dim colourLabelName As String
Dim textLabelCtrl As Label
Dim colourLabelCtrl As Label

While sqlDataReader.Read()
    ' Derive label names.
    textLabelName = "Label" & sqlDataReader("Lot_id").ToString() & "Text"
    colourLabelName = "Label" & sqlDataReader("Lot_id").ToString() & "Colour"

    ' Get Label controls with derived names.
    textLabelCtrl = CType(Me.FindControl(textLabelName), Label)
    colourLabelCtrl = CType(Me.FindControl(colourLabelName), Label)

    ' Set control properties for lot.
    lotStatus = sqlDataReader("status").ToString()
    If lotStatus = "occupied" Then
        textLabelCtrl.Text = sqlDataReader("Lot_id").ToString() & " is not available"
        colourLabelCtrl.BackColor = Drawing.Color.Red
    Else
        textLabelCtrl.Text = sqlDataReader("Lot_id").ToString() & " is available"
        colourLabelCtrl.BackColor = Drawing.Color.Green
    End If
End While







1. The ASP.NET Label control lacks the convenient Tag property of the WinForms control.



GeneralRe: reduce this big code Pin
duo!@#29-Jul-07 16:04
duo!@#29-Jul-07 16:04 
GeneralRe: reduce this big code Pin
Brady Kelly29-Jul-07 21:43
Brady Kelly29-Jul-07 21:43 
QuestionDeployement of web application Issue Pin
padmaja_200625-Jul-07 17:35
padmaja_200625-Jul-07 17:35 
QuestionMenu Control Formatting Pin
dwreck_stg25-Jul-07 15:50
dwreck_stg25-Jul-07 15:50 
AnswerRe: Menu Control Formatting Pin
dwreck_stg26-Jul-07 3:23
dwreck_stg26-Jul-07 3:23 
QuestionSSO Help Pin
Ridge Howison25-Jul-07 12:59
Ridge Howison25-Jul-07 12:59 
QuestionDisplay text with label [modified] Pin
ASPnoob25-Jul-07 12:48
ASPnoob25-Jul-07 12:48 
AnswerRe: Display text with label Pin
Christian Graus25-Jul-07 13:05
protectorChristian Graus25-Jul-07 13:05 
GeneralRe: Display text with label [modified] Pin
ASPnoob25-Jul-07 14:03
ASPnoob25-Jul-07 14:03 
GeneralRe: Display text with label Pin
doWhileSomething25-Jul-07 16:37
doWhileSomething25-Jul-07 16:37 
QuestionDB2 problem? Pin
kidus125-Jul-07 11:15
kidus125-Jul-07 11:15 
QuestionProblem with IIS7 & ASP 3 (Two) Pin
mehrdadc4825-Jul-07 9:46
mehrdadc4825-Jul-07 9:46 
AnswerRe: Problem with IIS7 & ASP 3 (Two) Pin
Guffa25-Jul-07 10:20
Guffa25-Jul-07 10:20 
AnswerRe: Problem with IIS7 & ASP 3 (Two) Pin
Fred_Smith25-Jul-07 12:42
Fred_Smith25-Jul-07 12:42 
QuestionProblem with IIS7 & ASP 3 (one) Pin
mehrdadc4825-Jul-07 9:44
mehrdadc4825-Jul-07 9:44 
QuestionError : Attempted to read or write protected memory Pin
morteza5725-Jul-07 7:51
morteza5725-Jul-07 7:51 
QuestionEmail with multiple address Pin
Sam Heller25-Jul-07 7:37
Sam Heller25-Jul-07 7:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.