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
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server" Width="386px" Height="409px">
<br />
<asp:TextBox ID="TxtSearch" runat="server" Height="16px" Width="125px"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" Height="16px"
ImageUrl="~/Images/SearchIcon.JPG" Width="20px" />
<br />
<div class="style1">
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
</telerik:RadScriptManager>
<telerik:RadGrid ID="GDSearch" runat ="server">
</telerik:RadGrid>
</div>
</asp:Panel>
</div>
</form>
Search.aspx.vb
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