Click here to Skip to main content
16,019,577 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

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
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
Posted
Updated 6-Dec-10 8:36am
v5

1 solution

Change this line:
VB
GDSearch.DataSource=myds


to
VB
GDSearch.DataSource=myds.Tables(0)
 
Share this answer
 
Comments
Rohit.Net100 6-Dec-10 13:53pm    
Tried it...but no change. Any alternates
Sandeep Mewara 6-Dec-10 13:56pm    
1. Did you used DEBUGGER and saw that there was some data in the dataset?
2. Did you used profiler and checked what query is being passed to database?
3. Did you run the raw query directly on DB and checked if there is any data related to it?
Rohit.Net100 6-Dec-10 14:26pm    
Checked everything..still no change.

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