Click here to Skip to main content
16,019,740 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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.
Posted

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.
 
Share this answer
 
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

XML
<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

VB
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
GDSearch.DataBind()
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900