You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a Web form that contains the following code fragment.
<asp:TextBox runat="server" ID="txtSearch" />
<asp:Button runat="server" ID="btnSearch" Text="Search" OnClick="btnSearch_Click" />
<asp:GridView runat="server" ID="gridCities" />
You write the following code segment in the code-behind file. (Line numbers are included for reference only.)
01 Protected Sub Page_Load(sender As Object, e As EventArgs)
02 Dim objDS__1 As New DataSet()
03 Dim objDA As New SqlDataAdapter(objCmd)
04 objDA.Fill(objDS__1)
05 gridCities.DataSource = objDs
06 gridCities.DataBind()
07 Session("ds") = objDS__1
08 End Sub
09 Protected Sub btnSearch_Click(sender As Object, e As EventArgs)
10
11 End Sub
You need to ensure that when the btnSearch Button control is clicked, the records in the gridCities GridView control are filtered by using the value of the txtSearch TextBox.
Which code segment you should insert at line 11?
A.
Dim ds As DataSet = TryCast(gridCities.DataSource, DataSet)
Dim dv As DataView = ds.Tables(0).DefaultView
dv.RowFilter = "CityName LIKE ‘" + txtSearch.Text & "%’"
gridCities.DataSource = dv
gridCities.DataBind()
B.
Dim ds As DataSet = TryCast(Session("ds"), DataSet)
Dim dv As DataView = ds.Tables(0).DefaultView
dv.RowFilter = "CityName LIKE ‘" + txtSearch.Text & "%’"
gridCities.DataSource = dv
gridCities.DataBind()
C.
Dim dt As DataTable = TryCast(Session("ds"), DataTable)
Dim dv As DataView = dt.DefaultView
dv.RowFilter = "CityName LIKE ‘" + txtSearch.Text & "%’"
gridCities.DataSource = dv
gridCities.DataBind()
D.
Dim ds As DataSet = TryCast(Session("ds"), DataSet)
Dim dt As DataTable = ds.Tables(0)
Dim rows As DataRow() = dt.[Select]("CityName LIKE ‘" + txtSearch.Text & "%’")
gridCities.DataSource = rows
gridCities.DataBind()