嗨,当我运行我的代码时,我收到了这个错误:
无法对 System.Int32 和 System.String 执行“Like”操作
我需要一种方法来允许 int 和 varchar 但想不出解决方案。我知道这与我的 id 选项是一个整数但想不出解决方案有关,非常感谢您的帮助。
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim FilterExpression As String = String.Concat(DropDownList1.SelectedValue, " LIKE " + "'%{0}%'")
SqlDataSource1.FilterParameters.Clear()
SqlDataSource1.FilterParameters.Add(New ControlParameter(DropDownList1.SelectedValue, "TextBox1", "Text"))
SqlDataSource1.FilterExpression = FilterExpression
End Sub
End Class