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();
SqlDataAdapter adp = null;
btnLoadMore.Visible = false;
cmd = new SqlCommand("GetStudentDetails_SP", con);
cmd.Parameters.AddWithValue("@topVal", numOfRows);
cmd.CommandType = CommandType.StoredProcedure;
adp = new SqlDataAdapter(cmd);
rptStudentDetails.DataSource = dt;
rptStudentDetails.DataBind();
rptStudentDetails.DataSource = null;
rptStudentDetails.DataBind();
ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Oops!! Error occured: " + ex.Message.ToString() + "');", true);
}
protected int rowCount()
{
SqlCommand cmd = new SqlCommand("GetStudentDetailsCount_SP", con);
cmd.CommandType = CommandType.StoredProcedure;
NoOfRows = Convert.ToInt32(cmd.ExecuteScalar());
ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "alert('Oops!! Error occured: " + ex.Message.ToString() + "');", true);
return NoOfRows;
}
protected void btnLoadMore_Click(object sender, EventArgs e)
{
int numVal = Convert.ToInt32(ViewState["num"]) + 4;
ViewState["num"] = numVal;
html file
<div style="position:relative; margin-top:1px;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<fieldset style="width:100%;">
<asp:Repeater runat="server" ID="rptStudentDetails">
<div class="single-product">
<a href=""><img src="images/p1.png" alt="Item Image"/></a>
<p class="productname"><a><%#Eval("SM_NAME") %></a></p>
<asp:Button ID="Button1" runat="server" Text="View All" Height="24" Width="75" BackColor="#50A748" ForeColor="#FFFFFF" CssClass="product_button" />
<div style="width: 59%; height: 50px; padding-top: 10px; padding-left: 42%; float: left;">
<asp:Button ID="btnLoadMore" runat="server" Text="Load More Data"
onclick="btnLoadMore_Click" />
<asp:UpdateProgress runat="server" ID="UpdateProgress1" DisplayAfter="10">
<img src="images/loading.gif" alt="wait image" />
</asp:UpdatePanel>
</div>
Please help me to solve my problem