or you could just not show the grid and show a message in its place if your
ds is empty.
something like
if(ds.row.count > 0)
{
show grid}
else
{
show no records found message
}
Hi,
I need o create it at runtime and I am having a few problems. On my
GridView ITemplate I have the following:
Dim edtPost As New TemplateField
edtPost.ItemTemplate = New edtPost(ListItemType.Item)
gvPosts.EmptyDataTemplate = edtPost
edtPost is a class as follows:
' edtPost
Private Class edtPost
Implements ITemplate
Private Type As ListItemType
Public Sub New(ByVal type As ListItemType)
Me.Type = type
End Sub ' New
Public Sub InstantiateIn(ByVal container As Control) Implements
ITemplate.InstantiateIn
' Select template type
Select Case Me.Type
Case ListItemType.Item ' Item template
Dim l As New Label
l.Text = "No Records Found"
container.Controls.Add(l)
End Select
End Sub ' InstantiateIn
End Class ' edtPost
I am getting the error:
Unable to cast object of type
'System.Web.UI.WebControls.TemplateField' to type
'System.Web.UI.ITemplate'.
On code line:
gvPosts.EmptyDataTemplate = edtPost
How can I solve this?
Thanks,
Miguel