|
|
|
start date: Tue, 21 Aug 2007 04:50:13 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
shapper
|
|
2
Ladislav Mrnka
|
|
3
Mike
|
|
4
unknown
|
|
5
shapper
|
Empty DataSet and GridView
Hello,
Is it possible to display a message in a GridView such as "No Records
Available" when the DataSet is empty?
Thanks,
Miguel
Date:Tue, 21 Aug 2007 04:50:13 -0700
Author:
|
RE: Empty DataSet and GridView
Hi Miguel,
GridView contains EmptyDataTemplate which is used in your case.
Regards,
Ladislav
"shapper" wrote:
> Hello,
>
> Is it possible to display a message in a GridView such as "No Records
> Available" when the DataSet is empty?
>
> Thanks,
>
> Miguel
>
>
Date:Tue, 21 Aug 2007 05:06:02 -0700
Author:
|
Re: Empty DataSet and GridView
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
}
"shapper" wrote in message
news:1187697013.850914.103730@r29g2000hsg.googlegroups.com...
> Hello,
>
> Is it possible to display a message in a GridView such as "No Records
> Available" when the DataSet is empty?
>
> Thanks,
>
> Miguel
>
Date:Tue, 21 Aug 2007 08:21:13 -0400
Author:
|
Re: Empty DataSet and GridView
On Aug 21, 7:50 am, shapper wrote:
> Hello,
>
> Is it possible to display a message in a GridView such as "No Records
> Available" when the DataSet is empty?
>
> Thanks,
>
> Miguel
You can also, if you would prefer the columns and grids did not
display as there is no data, to read the property Rows from the
GridView, and if (rows == 0) then alertLabel.Visible = true;
alertLabel.Text = "Blah blah"
Where an alertLabel is merely an invisible label you hide in your
screen to display only upon empty resultant sets.
Date:Tue, 21 Aug 2007 05:25:20 -0700
Author:
|
Re: Empty DataSet and GridView
On Aug 21, 1:21 pm, "Mike" wrote:
> 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
>
> }
> "shapper" wrote in message
>
> news:1187697013.850914.103730@r29g2000hsg.googlegroups.com...
>
> > Hello,
>
> > Is it possible to display a message in a GridView such as "No Records
> > Available" when the DataSet is empty?
>
> > Thanks,
>
> > Miguel
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
Date:Tue, 21 Aug 2007 07:40:31 -0700
Author:
|
|
|