Reputation: 109
I have to avoid page refresh. Every time I click the submit button, page is refreshed. How do I avoid that?
protected void Button1_Click(object sender, EventArgs e)
{
string firstname = DropDownList1.SelectedItem.Text;
if (firstname == "All")
{
da = new SqlDataAdapter(query, con);
}
dt = new DataTable();
dt = ds.DataTable1;
da.Fill(dt);
rdc.Load(Server.MapPath("CrystalReport.rpt"));
rdc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rdc;
CrystalReportViewer1.RefreshReport();
}
Upvotes: 0
Views: 906
Reputation: 44605
if you do not want a full page refresh either use UpdatePanel for partial rendering or proper ajax approach.
the way you are doing now with a server side button click is the slowest and generates a full page postback and refresh unless you use an UpdatePanel at minimum.
check here for a discussion on how to use the Crystal Report viewer with Ajax: using AJAX with crystal report viewer
Upvotes: 0
Reputation: 101
I would suggest putting everything that needs to be updated in an <asp:UpdatePanel>
.
You can find that control in the Ajax Control Toolkit
You will also have to add a <asp:ScriptManager>
on top of your page.
Upvotes: 1