11. december 2010 - 10:48Der er
7 kommentarer og 1 løsning
Kan denne code laves kortere
Dim nodata As Label = CType(MyRep.Controls(MyRep.Controls.Count - 1).FindControl("NoData"), Label) If nodata Is Nothing Then nodata.Text = "Der findes ingen data der machter din forespørgsel." End If
Dim lbl As Label = CType(MyRep.Controls(MyRep.Controls.Count - 1).FindControl("PValue"), Label)
If lbl Is Nothing Then lbl.Text = "0" Else lbl.Text = Q.ToList.Count() End If
Dim nodata As Label = CType(MyRep.Controls(MyRep.Controls.Count - 1).FindControl("NoData"), Label) If nodata Is Nothing Then nodata.Text = "Der findes ingen data der machter din forespørgsel."
Dim lbl As Label = CType(MyRep.Controls(MyRep.Controls.Count - 1).FindControl("PValue"), Label)
lbl.Text = Q.ToList.Count() If lbl Is Nothing Then lbl.Text = "0"
If MyRep.Controls.Count > 0 Then Dim lbl As Label = CType(MyRep.Controls(MyRep.Controls.Count - 1).FindControl("PValue"), Label) lbl.Text = Q.ToList.Count() Else nodata.Text = "Der findes ingen data der machter din forespørgsel." End If
Eventuelt:
If MyRep.Controls.Count > 0 Then Dim lbl As Label = CType(MyRep.Controls(MyRep.Controls.Count - 1).FindControl("PValue"), Label) If lbl Is Nothing Then Throw New Exception("Houston we have a problem") End If lbl.Text = Q.ToList.Count() Else nodata.Text = "Der findes ingen data der machter din forespørgsel." End If
Arne jeg måtte lige ændre lidt på det og så virker det for skal jo findcontrol("NoData")
If MyRep.Controls.Count > 0 Then Dim lbl As Label = CType(MyRep.Controls(MyRep.Controls.Count - 1).FindControl("PValue"), Label) If lbl Is Nothing Then Throw New Exception("Houston we have a problem") End If lbl.Text = Q.ToList.Count() Else Dim nodata As Label = CType(MyRep.Controls(MyRep.Controls.Count - 1).FindControl("NoData"), Label) nodata.Text = "Der findes ingen data der machter din forespørgsel." End If
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.