开发者

How to make GridView empty?

开发者_JS百科

I have a GridView and am displaying results by search button. For the first search it works fine, but when I click on second search, even if that search result does not exist, the old data is still displayed.

How can I make the GridView empty if there is no result found?

I used LINQ to SQL concept to display the search results.


You have to assign null as DataSource and then rebind the gridview e.g.

yourGridViewId.DataSource = null;
yourGridViewId.DataBind();


"emptydatatemplate" works better in my case:

<asp:Panel runat="server" ID="panelGrilla" CssClass="scrollable"  Height="350px" ScrollBars="Vertical">
    <asp:GridView ID="GridAcc" CssClass="cgrid" runat="server" AutoGenerateColumns="false" Width="100%">
        <emptydatatemplate>No data found</emptydatatemplate>
        <EmptyDataRowStyle HorizontalAlign="Center" />
    </asp:GridView>
</asp:Panel>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜