<EmptyDataTemplate> NOT WORKING ON GRIDVIEW CONTROL

I have a gridview

                    <asp:GridView ID="grdSearchResults" runat="server"
                    AutoGenerateColumns="False" DataKeyNames="PropertyID"
                    onselectedindexchanged="grdSearchResults_SelectedIndexChanged"
                    SkinID="GridViewSkin"
                    EmptyDataText="No properties have been returned - create new property below">
                        <columns>
                            <asp:boundfield DataField="PropertyID" Visible="False"></asp:boundfield>
                            <asp:boundfield DataField="Address1" HeaderText="Address"></asp:boundfield>
                            <asp:boundfield DataField="PostCode" HeaderText="Post Code"></asp:boundfield>
                            <asp:commandfield SelectText="Select This Property" ShowSelectButton="True">                          
                            </asp:commandfield>
</columns>    
                    </asp:GridView>


Here is the code to populate using subsonic..........

            Query qry = new Query("ClientProperty");
            qry.QueryType = QueryType.Select;
            if (txtAddress1.Text.Length > 1)
            {
                qry.AddWhere("ClientProperty", "Address1", Comparison.Like, txtAddress1.Text);
            }
            if (txtPostCode.Text.Length > 1)
            {
                qry.AddWhere("ClientProperty", "PostCode", Comparison.Like, txtPostCode.Text);
            }

            IDataReader myReader = qry.ExecuteReader();
            grdSearchResults.DataSource = myReader;
            grdSearchResults.DataBind();
            myReader.Close();


However if no results are returned the emptydatatemplate does not display



mugseyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gauravjoshiCommented:
create EmptyDataTemplate node and put your template inside it.

you can add this to your skin file if you have same msg to appear for all the grids you using.


Gaurav
<asp:GridView SkinId="SkinGridView"  runat="server" >
    <EmptyDataTemplate>
        No Records found
    </EmptyDataTemplate>
</asp:GridView>

Open in new window

0
mugseyAuthor Commented:
HI

Thanks I did this but still no text appears
If records are found then the gridview is displayed - else if no records then nothing
0
gauravjoshiCommented:
pls send me skin  and gridview code

I would like to test it on my pc

Gaurav
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

mugseyAuthor Commented:
HI Gaurav

Thanks for your comment.  I will have to wait until Monday now but will post asap!
Thanks!
0
mugseyAuthor Commented:

Here is the gridview CSS
 
TABLE.gv
{
   border-bottom:solid 2px #aaaaaa;
   width:100%; 
}
 
 
TABLE.gv TH
{
    background-color:#8f8ab6;
    color:#ffffff;
}
 
TABLE.gv TH a,
TABLE.gv TH a:link,
TABLE.gv TH a:active,
TABLE.gv TH a:hover,
TABLE.gv TH a:visited
{
    color:#ffffff;
}
 
TABLE.gv TR.footer
{
    background-color:#cccccc;
}
 
TABLE.gv TR.alt
{
    background-color:#F5FAFA;
}
 
TABLE.gv TR.selected
{
    background-color:Highlight;
    color:#ffffff;
}
 
TABLE.gv TR.selected a
{
   color:#ffffff; 
}
 
****************
 
Here is the gridview skin
 
 
<asp:GridView runat="server" SkinId="GridViewSkin" CssClass="gv" CellPadding=5>
    <AlternatingRowStyle CssClass="alt" />
    <FooterStyle CssClass="footer" />
    <SelectedRowStyle CssClass="selected" />        
</asp:GridView>

Open in new window

0
gauravjoshiCommented:
<asp:GridView runat="server" SkinId="GridViewSkin" CssClass="gv" CellPadding=5>
    <AlternatingRowStyle CssClass="alt" />
    <FooterStyle CssClass="footer" />
    <SelectedRowStyle CssClass="selected" />
 <EmptyDataTemplate>
        No Records found
    </EmptyDataTemplate>
</asp:GridView>


Try this out, also just make sure, the text font color is not white, i mean it is not getting mixed with background,


Gaurav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.