I am running a stored procedure and presenting the data back to users in a simple datagridview. I'm unable to figure out a way to filter my data through the SQL side, so I wanted to see if I could filter data through the datagridview.
Basically my sql query returns back values of "activity" that are either added or deleted, and I only want to present data back to users that are "added.' Is there a way to do this by filtering the contents of the datagridview?
This is what I have in my codebehind for the page for both the SQL connection string, and the stored procedure. I'm assuming that this would be where I would filter the information.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles oncallsubmitButton.Click
Dim dt As New DataTable
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim connectionString As String = "Initial Catalog=xxxxx;Data Source=xxxxx;uid=xxxxx;password=xxxxx"
Dim con As New SqlConnection(connectionString)
con.Open()
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_owncalls"
cmd.Parameters.AddWithValue("@schedname", schednameTextBox.Text)
Try
da.SelectCommand = cmd
da.Fill(dt)
GridView1.DataSource = Nothing
GridView1.DataBind()
con.Dispose()
Catch ex As Exception
Response.Write("Error:" & ex.ToString)
If (Me.GridView1.Rows.Count <= 0) Then
nodataLabel.Text = "No data available"
End If
End Try
End Sub
Any help is appreciated.
Thank you
Doug