다음 코드 줄이 있습니다.
Protected Sub RepComisiones_ItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles RepComisiones.ItemDataBound
Dim valoresRepeter As DataRowView
If e.Item.ItemType = ListItemType.Item Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
valoresRepeter = e.Item.DataItem
Select Case valoresRepeter("ECO").ToString
Case "0"
CType(e.Item.FindControl("lblEco"), Label).Text = ""
End Select
Select Case valoresRepeter("A").ToString
Case 0
CType(e.Item.FindControl("lblA"), Label).Text = ""
End Select
Select Case valoresRepeter("B1").ToString
Case 0
CType(e.Item.FindControl("lblB1"), Label).Text = ""
End Select
Select Case valoresRepeter("B2").ToString
Case 0
CType(e.Item.FindControl("lblB2"), Label).Text = ""
End Select
Select Case valoresRepeter("B3").ToString
Case 0
CType(e.Item.FindControl("lblB3"), Label).Text = ""
End Select
Select Case valoresRepeter("B3P").ToString
Case 0
CType(e.Item.FindControl("lblB3P"), Label).Text = ""
End Select
End If
End Sub
몇 줄을 줄이고 다른 방법을 시도하지만 결과가 정확하지 않습니다. 어떻게 최적화 할 수 있는지 알 수 없습니다.
감사합니다
간단하고 깨끗한 해결책은 모든 키 ( "ECO", "A", "B1") 및 해당 컨트롤 이름 ( "lblECO", "lblA", "lblB")을 사전에 넣고이를 위해 반복하는 것입니다. 개별 조건 평가.
Private mappings As New Dictionary(Of String, String) From
{
{"ECO", "lblEco"},
{"A", "lblA"},
{"B1", "lblB1"}
}
Sub RepComisiones_ItemDataBound()
For Each key As String In mappings.Keys
If valoresRepeter(key).ToString Is "0" Then
DirectCast(e.Item.FindControl(mappings.Item(key)), Label).Text = ""
End If
Next
End Sub
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다