How to stop Autopost back in pageload

Posted by Abhisekjani under ASP.NET on 6/29/2012 | Points: 10 | Views : 2304 | Status : [Member] | Replies : 6
Hi
while i selected a gridrow in gridview the page will autoloaded and the control goes to first row ........
How to stop autopostback in page load




Responses

Posted by: Johnbhatt on: 6/29/2012 [Member] Starter | Points: 25

Up
0
Down
Use below code On Page_Load event to avoid Postback everytime.

if (!IsPostBack)
{
GridView1Fill(); // Code to Bind Data to GridView.
}


John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Johnbhatt on: 7/2/2012 [Member] Starter | Points: 25

Up
0
Down
Dear Abhisek,
If your query is solved please mark as answer and close forum post.

John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com

Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhisekjani on: 7/2/2012 [Member] Starter | Points: 25

Up
0
Down
No its not working....while i select a row in gridview the focus goes to first row mean if i select a row the page got autopostback......i want if i select a row the focus should be at the selected row.........

Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muralidosscm on: 7/3/2012 [Member] Starter | Points: 25

Up
0
Down
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
{
}



Regards
Muralidoss M

Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhisekjani on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
its not working...................


Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Premalatha on: 7/4/2012 [Member] Starter | Points: 25

Up
0
Down
Use a Flag, like IsPopUpShown and add it in the session.

like:


if(!Page.IsPostBack)
{
bool _isShownInSession = (null != Session["IsPopUpShown"])?Convert.ToBoolean(Session["IsPopUpShown"]) : false;

if(isShownInSession == false)
{
//Show PopUp
Session["IsPopUpShown"] = true;
}
}


Hope This helps :)

Premalatha
Software Engineer

Abhisekjani, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response