Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
i am facing a problem as my list view not showing any result, in the index page of my application i have SrchtxtBox which query string will be created depending on text entering and then passed to another page which is adsdetail.aspx. here is the code on textbox in the index page:

C#
Response.Redirect("SearchResult.aspx?Searchfor=" + Srchtxt.Text);


and here is the code of my listview on adsdetail.aspx which not showing any result:

C#
if (!IsPostBack)
            {
                string result = Convert.ToString(Request.QueryString["Searchfor"]);
                
                if (Request.QueryString["Searchfor"] != null)
                {

                    HttpCookie cookie = Request.Cookies.Get("Location");

                    if (cookie["Location"] != null)
                    {

                        using (SqlConnection srchsql = new SqlConnection(sc))
                        {
                            // Open your connection
                            srchsql.Open();

                            // Build your data adapter
                            SqlDataAdapter DAsearch = new SqlDataAdapter("SELECT [AdsID], [AdsDate], [AdsPrice], [AdsTit], SUBSTRING([AdsDesc],1,50) as AdsDesc, [Section], [Category], [Wtags], [Country], [State], [City],[Img1] FROM [ads] WHERE (([Country] = @Country) AND ([Wtags] = @Wtags))", sc);
                           
                            // Define your data set
                            DataSet DSsrchP = new DataSet();
                            
                            // Add your parameters to your data adapter
                            DAsearch.SelectCommand.Parameters.AddWithValue("@Country", cookie.Value);
                            DAsearch.SelectCommand.Parameters.AddWithValue("@Wtags", result);



                            // Fill your data set
                            DAsearch.Fill(DSsrchP);

                            // Bind your results
                            resultshowlistview.DataSource = DSsrchP.Tables[0];
                            resultshowlistview.DataBind();
                        }
                    }
                    else
                    {
                        // Your Session key could not be found, consider displaying an error
                    }
                }
            }
Posted
Comments
Arjsrya 2-Jan-15 2:28am    
Did you check the table has data for that particular query string?
Maciej Los 2-Jan-15 16:29pm    
Not enough information... for example: you did not provide information about DAL.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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