display empty grid

N

Nikhil Patel

Hi,
The grid is not displayed when it is bound to an empty dataset. I need to
display just the header of the grid when the dataset is empty. How can I do
this?

Thanks...
-Nikhil
 
S

suresh kojhani

Dear Nikil

I have same problem...please if u find answer of this qurey then tell me
... i will be thank ful to u?

bye

suresh
 
K

Ken Cox [Microsoft MVP]

Are you binding to a datatable or a dataset? The code below seems to product
the header with no data:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim dt As New DataTable
dt = CreateDataSource()
If dt.Rows.Count = 0 Then
End If
DataGrid1.DataSource = dt
DataGrid1.DataBind()
End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
'Dim i As Integer
'For i = 0 To 8
' dr = dt.NewRow()
' dr(0) = i
' dr(1) = "Item " + i.ToString()
' dr(2) = 1.23 * (i + 1)
' dr(3) = (i = 4)
' dt.Rows.Add(dr)
'Next i
Return dt
End Function 'CreateDataSource
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top