I have the following page and what I'd like to be able to do is that when the user clicks on the clear button that it disposes of the results of the datagridview and reloads the page. What would be the best way to go about doing that?
Code:Imports System.Data.SqlClient Imports System.Data Partial Class _Default Inherits System.Web.UI.Page Protected Sub whosoncallButton_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles whosoncallButton.Click Dim dt As New DataTable Dim da As New SqlDataAdapter Dim cmd As New SqlCommand Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx" Dim con As New SqlConnection(connectionString) con.Open() cmd.Connection = con cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "getoncall" cmd.Parameters.AddWithValue("@subschedule", TextBox1.Text) Try da.SelectCommand = cmd da.Fill(dt) GridView1.DataSource = dt GridView1.DataBind() con.Dispose() Catch ex As Exception Response.Write("Error:" & ex.ToString) End Try End Sub Protected Sub clearButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles clearButton.Click TextBox1.Text = "" GridView1.DataSource = Nothing End Sub




Reply With Quote