I'm working on a web page, I need that when it loads first time it would get data from api's.
Then I want to go from page to page with the same data.
I used IsPostBack
Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//First Time Load Data
leadsList = new List<Lead>();
var client = TVPLeads.Session.GetWebClient(Session);
string PostId = PostId = Request.QueryString["postId"];
PostId = "1";
try
{
leadsList = API.GetPostLeads(client, PostId);
}
catch (Exception) { }
page = (page == 0) ? 0 : page - 1;
DisplayLeadsPage(leadsList, page, "");
}
}
private void pageChoosen(object sender, EventArgs e)
{
int page = int.Parse(((Button)sender).CommandArgument);
DisplayLeadsPage(leadsList, page-1, "");
}
DisplayPagination(){
.
.
Button prev = new Button{
ID = "page_"+i,
CssClass = "Pagination",
Text = "i",
CommandArgument = ""+i,
OnClientClick = "pageChoosen"
};
prev.Click += pageChoosen;
divPagination.Controls.Add(prev);
.
.
.
}
I clicking on a button , got to Page_Load function the postBack is true as expected , but the function is not firing(checked with debugger).
- if I remove the IsPostBack and it would make all over again , then the button function is firing.
What's the problem with that? How to use it right ?