Monday 26 December 2011

How To Show the Header of GridView When Data Source is nothing


There is a big Problem when Gridview Do not get the Datasource then it do not shows its Header. For Showing the header of Gridview when Data Source is nothing:

Public Sub BindAddress(ByVal id As Integer)
        Dim sql As String
   sql = "select id,Name,Mobile,bill_type_id,client_id,(select data from master_data md where md.data_id = ca.bill_type_id) as bill_type, Address1,Address2,Address3,"
        sql = sql & " case when bill_type_id = 6 then 1 else 0 end as RdAdd1"
        sql = sql & " from client_address ca where client_id =" & id

   Dim da As SqlDataAdapter = New SqlDataAdapter(sql, conn)
        Dim ds As DataSet = New DataSet()
        da.Fill(ds, "AddTbl")
        If ds.Tables(0).Rows.Count > 0 Then
            GdvAdd.DataSource = ds.Tables("AddTbl")
            GdvAdd.DataBind()
        Else
         ds.Tables(0).Rows.Add(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
         GdvAdd.DataSource = ds.Tables("AddTbl")
         GdvAdd.DataBind()
         GdvAdd.Rows(0).Visible = False
        End If

    End Sub

1 comment: