The SQLDataSource

 

 

1.    Drop an SQLDatasource on your webpage and configure like below…

 

Figure1.jpg

 

Notice the Column: Operator: and Source: fields on the dialog box.  I’ve temporarily entered a value of “young”.  (We’ll be changing this value via code later)

 

 

 

 

 

2.    Drop the GridView control on your form, set the datasource to the sqlDataSource and “enable editing”

Figure2.jpg

 

 

 

3.    To change the “Select” parameter programmatically, use the code below…

 

   Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting

 

 

        e.Command.Parameters("@CandidateName").Value = "smith"

 

    End Sub

 

 

 

Here’s how to filter the sqlDatasource…

 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

        SqlDataSource1.FilterExpression = "CandidateName like '%gay%'"

 

    End Sub