I have a gridview that is being populated from a sql database. When the results are displayed I am linking the district #'s to a new contact page for each one. Ex. d1.aspx, d2.aspx, d3.aspx etc. On each of those pages there is a link to return back to the orginal page. When this happens the original page is refrreshed and the previous gridview results are gone. Is it possible to stop this from happening or is there a better way to do something like this?
<Columns>
<asp:BoundField HeaderText="Name" DataField="school" /><asp:BoundField />
<asp:TemplateField HeaderText="District" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("district", "cdms/d{0}.aspx") %>' Text='<%# Eval("district") %>'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<span style="color: rgb(255, 0, 0);">No records found!</span>
</EmptyDataTemplate>
</asp:GridView>
Codebehind:
protected void btnSubmit_Click(object sender, EventArgs e)
{
BuildGridView1();
GridView1.DataBind();
GridView1.Visible = true;
}
private void BuildGridView1()
{
GridView1.DataSource = new Select(District.Schema.TableName + ".*")
.From(District.Schema)
.Where(District.Columns.Zip).IsEqualTo(this.txtZip.Text)
.OrderAsc(District.Columns.Zip)
.ExecuteDataSet();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
BuildGridView1();
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}