使用txtbox的输入进行RAD Grid Search查询 [英] RAD Grid Search Query using input from txtbox
本文介绍了使用txtbox的输入进行RAD Grid Search查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在.aspx页上有一个TxtBox,Btn和RadGrid,输入任何值时,它将在sqldatabase中搜索数据,并必须在RADGRID中显示结果.
我必须在VB.NET中进行此可编程性.
这是我尝试过的方法,但是当我在文本框中输入数据并单击btn时,我的网格无法显示.请让我知道我在想什么.
我的.aspx和.vb代码如下.
提前谢谢.
Search.aspx
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
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
推荐答案
更改此行:
Change this line:
GDSearch.DataSource=myds
到
to
GDSearch.DataSource=myds.Tables(0)
这篇关于使用txtbox的输入进行RAD Grid Search查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文