Hi Friends,
Am using ASP.Net framework 2.0, my problem is when i load data to repeater control from database the whole web page is refreshing. "Load More Button" is used to retrieve more data from database. I need only repeater control should be refreshed when i click "Load More Button".
Here is the code,
aspx file
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack){
num = 4;ViewState["num"] = num;BindRepeater(num);
}
}
public void BindRepeater(int numOfRows)
{
DataTable dt = new DataTable();SqlCommand cmd = null;SqlDataAdapter adp = null;
try{
int rCount = rowCount();if (numOfRows > rCount){
btnLoadMore.Visible = false;
}
cmd = new SqlCommand("GetStudentDetails_SP", con);cmd.Parameters.AddWithValue("@topVal", numOfRows);cmd.CommandType = CommandType.StoredProcedure;adp = new SqlDataAdapter(cmd);adp.Fill(dt);
if (dt.Rows.Count > 0){
rptStudentDetails.DataSource = dt;rptStudentDetails.DataBind();
}else{
rptStudentDetails.DataSource = null;rptStudentDetails.DataBind();
}
}catch (Exception ex){
ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Oops!! Error occured: " + ex.Message.ToString() + "');", true);
}finally{
con.Close();cmd.Dispose();adp = null;dt.Clear();dt.Dispose();
}
}
protected int rowCount()
{
int NoOfRows = 0;SqlCommand cmd = new SqlCommand("GetStudentDetailsCount_SP", con);cmd.CommandType = CommandType.StoredProcedure;try{
con.Open();NoOfRows = Convert.ToInt32(cmd.ExecuteScalar());
}catch (Exception ex){
ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Oops!! Error occured: " + ex.Message.ToString() + "');", true);
}finally{
con.Close();cmd.Dispose();
}
return NoOfRows;
}
protected void btnLoadMore_Click(object sender, EventArgs e)
{
int numVal = Convert.ToInt32(ViewState["num"]) + 4;BindRepeater(numVal);ViewState["num"] = numVal;
}
html file
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

KalaiPosted Aug 26, 2014, 7:33 AM
http://www.aspdotnet-suresh.com/2012/05/ajax-updapanel-control-with-triggers.html
Harish MPosted Aug 30, 2014, 7:59 AM
Thanks a lot kalai, problem is solved. I got what i expected.
Harish MPosted Aug 26, 2014, 7:30 AM
Thanks for your reply. I added your lines of code but same result. The whole page is refreshing. Please give me another solution to solve this problem !!
KalaiPosted Aug 26, 2014, 7:17 AM