在datagrid中添加“找不到记录”的文本

时间:2014-04-15 14:19:35

标签: vb.net datagrid

如果DataGrid为空,我想要一条消息,但此刻什么都没有,这是我的代码:

Private Sub fill_tbldespesas()
        Dim ds As New DataSet
        Dim BD_SimuladorNT As New Negocio.Simulador.SimulacoesNT
        ds = BD_SimuladorNT.Fill_DGDespesas(CurrentContext.CurrentUserId, CurrentContext.CurrentCulture.idCulture)
        Dim dv As DataView
    If (Not (dv Is Nothing)) Then
        If ds.Tables.Count > 0 Then
            dv = ds.Tables(0).DefaultView
            dv.RowFilter = "IncluidaProp = 'T'"
            dgdespesas.DataSource = dv
            dgdespesas.DataBind()
        End If

        If ds.Tables.Count < 1 Then
            Dim lblempty As Label = DirectCast(FindControl("lblgridEmpty"), Label)
            dgdespesas.DataSource = Nothing
            Me.dgdespesas.ShowHeader = False
            'gridEmpty.text = "Company Name must not be empty"
            'dgdespesas.rows.clear()
            lblempty.Text = "no results"

        End If
    End If
End Sub

0 个答案:

没有答案