How can you clear GridView by clicking a button?

Ddd
Posted by Ddd under ASP.NET category on | Points: 40 | Views : 4365
use this code snippet.

protected void Page_Load(object sender, EventArgs e)
{
List<string> s = new List<string>();
s.Add("vb");
s.Add("csharp");
GridView1.DataSource = s;
GridView1.DataBind();

}
protected void Button1_Click(object sender, EventArgs e)
{
GridView1.DataSource = null;
GridView1.DataBind();

}

Comments or Responses

Login to post response