我的转发器控件显示加载时的数据库字段。
我在中继器控件之外有一个搜索按钮。按下按钮时,我希望中继器仅显示中继器中的搜索结果。我怎样才能做到这一点?
这是显示所有的代码。在搜索时,我不想在中继器中显示下面的详细信息。只是搜索结果。
Protected Sub BindRepeater() Dim cmd As New SqlCommand("Select * from abc", con)
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim ds As New DataSet()
Dim adp As New SqlDataAdapter(cmd)
adp.Fill(ds)
' Repeater1.DataSource = ds
Repeater1.DataBind()
con.Close()
下面结束子是我在搜索按钮中添加的新代码
cmd = New SqlCommand
cmd.Connection = con
cmd.CommandText = "select * from ABC where LicenseID = '" & TextBox16.Text & "'"
drd = cmd.ExecuteReader
If drd.HasRows = True Then
drd.Read()
End If
Using con = New SqlConnection("Data Source=ABC-556012RT13\SQLEXPRESS;Initial Catalog=KABC;Integrated Security=True")
Using da = New SqlDataAdapter("select * from ABC where LicenseID = @LicenseID", con)
da.SelectCommand.Parameters.AddWithValue("@LicenseID", TextBox16.Text)
Dim table = New DataTable
da.Fill(table)
Repeater1.DataSource = table
Repeater1.DataBind()
End Using
End Using