如何清除网格视图中的所有记录? [英] How to clear all the records in grid view?

查看:116
本文介绍了如何清除网格视图中的所有记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我有一个名为Clear的按钮。如果用户选择该按钮,则所有文本框值都将被清除,我的网格视图也不应包含任何记录。但是不应该在数据库中删除这些记录。我需要的是网格视图将首先显示无可用记录,就像单击清除按钮时刷新页面一样。任何帮助?

Hi guys!

I have a button named Clear. If the user selects that button, all the text boxes values will be cleared also my grid view should not contain any records. But those records should not be deleted in the database. What I need is that the grid view will first display"No Available Records", it is like refreshing the page when I click the Clear Button. Any help?

推荐答案

您可以在gridview中使用EmptyDataTemplate来显示无可用记录

例如,您要清除gridview中的记录

在HTML方面

You can use EmptyDataTemplate in gridview to show No Available Records
As for example you want clear the records from gridview
In HTML Side
<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
           <columns>
            <%--   Put your column names--%>
           </columns>
           <emptydatatemplate>
               No Available Records
           </emptydatatemplate>
       </asp:gridview>



代码背后的代码清除按钮


In code behind At clear button

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


那么问题是什么。在按钮上点击你可以像这样编码



//在你的按钮中点击调用此函数



So what is the problem .In Button Click you can code like this

//In your Button Click call this Function

private void ClearAll()
{
//here clear all your text box and to clear your gridvie here is the code
TextBox1.Text = "";
 gridview.datasource=null;
 gridview.databind();

}


这篇关于如何清除网格视图中的所有记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆