使用TextBox值填充RADGRID [英] Populate RADGRID with TextBox Value

查看:77
本文介绍了使用TextBox值填充RADGRID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.aspx页面上有一个TxtBox和Btn以及RadGrid,当输入任何值时,它将搜索sqldatabase中的数据并且必须在RADGRID中显示结果。

我必须执行此可编程性在VB.NET。



任何帮助都表示赞赏。

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.

Any help is appreciated.

推荐答案

看起来像一个简单的搜索页面!到目前为止你尝试了什么?



1.创建一个ASP.NET网站

2.创建一个新的搜索页面(ASPX)

3.现在,在此搜索页面中,放置一个文本框,按钮&数据网格

4.在按钮单击事件中,获取在文本框中输入的文本。使用该文本形成一个搜索查询,您将在数据库中运行以获取结果

5.从数据库中检索数据后,使用该数据集/数据表并将其绑定到数据网格以进行显示。 />
试试!





要使用代码连接数据库,请尝试使用ADO.NET。看看这里 [ ^ ]。
Looks like a simple search page! What have you tried so far?

1. Create a ASP.NET website
2. Create a new search page(ASPX)
3. Now, in this search page, place a textbox, button & a datagrid
4. In button click event, fetch the text entered in the textbox. Use the text to form a search query that you will run ion the database to get back result
5. Once data retrieved from DB, use that dataset/datatable and bind it to datagrid for display.
Try!


For connection with DB using code, try ADO.NET. have a look here[^] for it.


这是我试过的,但是当我在文本框中输入数据并单击btn时,我的网格不显示。请让我知道我错过了什么。

我的.aspx和.vb代码如下。

提前致谢。



Search.aspx



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

进口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

导入System.Dat a.SqlClient

进口Telerik.Web.UI



公共类SearchItems

继承System.Web.UI .Page






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 =选择X1,X2,X3,X4来自TABLE1其中Y1 LIKE @ Y1按Y1排序

myda.SelectCommand.Parameters.AddWithValue(@ Y1,TxtSearch.Text& %)

myda.SelectCommand.CommandType = CommandType.Text

myda.Fill(myds)

GDSearch.DataSource = myds

GDSearch.DataBind()


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
GDSearch.DataBind()


这篇关于使用TextBox值填充RADGRID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆