mugsey
asked on
<EmptyDataTemplate> NOT WORKING ON GRIDVIEW CONTROL
I have a gridview
<asp:GridView ID="grdSearchResults" runat="server"
AutoGenerateColumns="False " DataKeyNames="PropertyID"
onselectedindexchanged="gr dSearchRes ults_Selec tedIndexCh anged"
SkinID="GridViewSkin"
EmptyDataText="No properties have been returned - create new property below">
<columns>
<asp:boundfield DataField="PropertyID" Visible="False"></asp:boun dfield>
<asp:boundfield DataField="Address1" HeaderText="Address"></asp :boundfiel d>
<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("ClientProper ty", "Address1", Comparison.Like, txtAddress1.Text);
}
if (txtPostCode.Text.Length > 1)
{
qry.AddWhere("ClientProper ty", "PostCode", Comparison.Like, txtPostCode.Text);
}
IDataReader myReader = qry.ExecuteReader();
grdSearchResults.DataSourc e = myReader;
grdSearchResults.DataBind( );
myReader.Close();
However if no results are returned the emptydatatemplate does not display
<asp:GridView ID="grdSearchResults" runat="server"
AutoGenerateColumns="False
onselectedindexchanged="gr
SkinID="GridViewSkin"
EmptyDataText="No properties have been returned - create new property below">
<columns>
<asp:boundfield DataField="PropertyID" Visible="False"></asp:boun
<asp:boundfield DataField="Address1" HeaderText="Address"></asp
<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("ClientProper
}
if (txtPostCode.Text.Length > 1)
{
qry.AddWhere("ClientProper
}
IDataReader myReader = qry.ExecuteReader();
grdSearchResults.DataSourc
grdSearchResults.DataBind(
myReader.Close();
However if no results are returned the emptydatatemplate does not display
ASKER
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
Thanks I did this but still no text appears
If records are found then the gridview is displayed - else if no records then nothing
pls send me skin and gridview code
I would like to test it on my pc
Gaurav
I would like to test it on my pc
Gaurav
ASKER
HI Gaurav
Thanks for your comment. I will have to wait until Monday now but will post asap!
Thanks!
Thanks for your comment. I will have to wait until Monday now but will post asap!
Thanks!
ASKER
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you can add this to your skin file if you have same msg to appear for all the grids you using.
Gaurav
Open in new window