Advertisement

01.31.2008 at 07:08AM PST, ID: 23126428
[x]
Attachment Details

<EmptyDataTemplate> NOT WORKING ON GRIDVIEW CONTROL

Asked by mugsey in .Net Editors & IDEs, C# Programming Language, Programming for ASP.NET

Tags: GRIDVIEW ASP.NET C#

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



Start Free Trial
[+][-]01.31.2008 at 12:08PM PST, ID: 20790488

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.31.2008 at 12:14PM PST, ID: 20790541

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.31.2008 at 12:47PM PST, ID: 20790913

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.31.2008 at 01:24PM PST, ID: 20791338

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.04.2008 at 02:23AM PST, ID: 20813154

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.04.2008 at 10:18AM PST, ID: 20816645

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, C# Programming Language, Programming for ASP.NET
Tags: GRIDVIEW ASP.NET C#
Sign Up Now!
Solution Provided By: gauravjoshi
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628