Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted
Updated 1-Sep-14 16:13pm
v2

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();
 
Share this answer
 
So what is the problem .In Button Click you can code like this

//In your Button Click call this Function

C#
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();

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900