Gridview won't rebind data after changing Gridview page

marian

New Member
I am trying to populate my gridview with amazon search results. At the moment when the page loads, datasource is filled with data. What I am trying to do is show the data after pressing the Search button, but it displays "No Records Found". I have tried many different ways, the only way it worked, was without postback, but then the issue was that every time I changed the page on the gridview, GetProducts("Playstation") command was initiated over again. The solution I have been searcing for: Load the page -> click button -> fill the gridview with data -> When choosing new page in gridview, data is displayed but Getproducts("Playstation") is not initiated again. Is there a way to do this ? \[code\]protected void Page_Load(object sender, EventArgs e) { Button1.Click += new EventHandler(this.GreetingBtn_Click); if (!Page.IsPostBack) { AmazonSearch us = new Amazon.PAAPI.AmazonSearch(); GridView1.DataSource = us.GetProducts("Playstation"); }}void Search(Object sender, EventArgs e) { Button clickedButton = (Button) sender; GridView1.DataBind();}protected void grid_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind();}\[/code\]
 
Back
Top