Search Query based on TextBox Input

.net , , Miami, United States
  • 10 years ago

    I have a TxtBox and Btn and RadGrid on my .aspx page, when entering any value, it will search data in sqldatabase and have to show results in RADGRID. I have to do this programmability in VB.NET.

    This is what i have tried, but my grid not displaying when i enter data in textbox and click the btn. Please let me know what i am missing. My .aspx and .vb code is below. Thanks in advance.

    Search.aspx Collapse

    Search.aspx.vb Collapse Imports System.Data Imports System.Configuration Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Imports System.Data.SqlClient Imports Telerik.Web.UI

    Public Class SearchItems Inherits System.Web.UI.Page

    Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click Dim myconn As New SqlConnection(ConfigurationManager.ConnectionStrings("MYConnectionString").ConnectionString) Dim myda As New SqlDataAdapter() Dim myds As New DataSet() myda.SelectCommand = New SqlCommand myda.SelectCommand.Connection = myconn myda.SelectCommand.CommandText = "Select X1, X2, X3, X4 From TABLE1 Where Y1 LIKE @Y1 Order By Y1" myda.SelectCommand.Parameters.AddWithValue("@Y1", TxtSearch.Text & "%") myda.SelectCommand.CommandType = CommandType.Text myda.Fill(myds) GDSearch.DataSource=myds.Tables(0) GDSearch.DataBind() End Sub

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“My definition of an expert in any field is a person who knows enough about what's really going on to be scared.” - P. J. Plauger