每当我尝试点击Gridview内的搜索按钮或选择按钮时,整个页面会重新加载并向上滚动。我希望它保持在原地。怎么做?
代码:
代码:
<asp:TextBox ID="txtComplaintSubject" runat="server" CssClass="textField_width"></asp:TextBox> 
<asp:Button ID="btnSearch" CssClass="btn btn-success" runat="server" Text="Search"
ValidationGroup="AdminRole" ClientIDMode="Static" OnClick="btnSearch_Click" />
<asp:GridView ID="gridViewComplaints" AutoGenerateSelectButton="true" runat="server" CssClass="mGrid" OnSelectedIndexChanged="gridViewComplaints_SelectedIndexChanged">
<EmptyDataRowStyle BorderStyle="None" ForeColor="Red" BorderWidth="0px" />
<EmptyDataTemplate>
No Data Found for this Input. Try Again.
</EmptyDataTemplate>
<SelectedRowStyle CssClass="selected-row" BackColor="YellowGreen" ForeColor="white" />
</asp:GridView>
protected void btnSearch_Click(object sender, EventArgs e)
{
ManageComposedLetter mngCompLetter = new ManageComposedLetter();
DataTable dt = mngCompLetter.FillGridView_Complaints(txtComplaintSubject.Text);
if (dt.Rows.Count > 0)
{
gridViewComplaints.DataSource = dt;
gridViewComplaints.DataBind();
}
else
{
dt.Rows.Add(dt.NewRow());
gridViewComplaints.DataSource = dt;
gridViewComplaints.DataBind();
int totalcolums = gridViewComplaints.Rows[0].Cells.Count;
gridViewComplaints.Rows[0].Cells.Clear();
gridViewComplaints.Rows[0].Cells.Add(new TableCell());
gridViewComplaints.Rows[0].Cells[0].ColumnSpan = totalcolums;
gridViewComplaints.Rows[0].Cells[0].Text = "No Data Found";
}
}