Link to home
Start Free TrialLog in
Avatar of alain123
alain123

asked on

flow problem

oninit()

load form...

oninit() again

reload form ...


IsPostBack()
{

}

submitbutton_event(){
getvalues from form
createdatagrid();

}


DataGridsortevent(){
createdatagrid();
}


DataGridpagingevent
{
createdatagrid();
}


GridItemDataBound()
{
//do adding
}

everytime i click on a datagrid event(sorting,paging) it will go trough oninit() , recreate original form and lose datagrid..  so, is there a way to find out if the datagrid exists on the form? i'm trying to use viewstate/setting a variable and nothing, not sure either that's a good way to do it.. thank you
Avatar of msdixon
msdixon

i assume this is asp.net...

in your init method do the following:

protected void Page_OnInit(object sender, EventArgs e)
{
   if (!Page.IsPostBack)
   {
      // build your grid here
   }
}
Avatar of alain123

ASKER

hi ms,

yes it's asp .net c#..

if i do that then it will build/add the datagrid to the form there, and it will then go to

submitbutton_event(){    
getvalues from form  --> will fail, form will not exist
createdatagrid();

}
 the form will be the datagrid, i won't be able to capture the values from the user....
actually it will exist. i usually use the page load event to build my grids, but it should have the same effect using page init. the view state will have all the information in the grid.

did you try it?

maybe there's something in your method that you need to do every time the page is loaded, not just the initial occurrence.
yes i did tried ...  i agree with you, the datagrid will exists, but the original form with the userinfo dissapears.. which is what i need before loading the datagrid
if you post some more code i can take a look at it.
hmm i wish i could ms, it's way too big and distributed among multiple classes..
well..... without taking a look at some code.... it appears that something you're calling in your init event needs to be called on every load and the databinding stuff doesn't. i know that doesn't really help a whole lot.
ASKER CERTIFIED SOLUTION
Avatar of TheAvenger
TheAvenger
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Post?

that's the answer?