Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
350
editRow doesn't work after postback
posted

I have the following javascript function:

function ClickCellButton(sGridId, sCellId)

{

var activeRow = igtbl_getGridById(sGridId).getActiveRow();

activeRow.editRow();

}

And following code behind:

protected void Page_Load(object sender, EventArgs e)

{

ITemplate template;template = Page.LoadTemplate("webcontrols/someTemplate.ascx");

UltraWebGrid1.Bands[0].RowEditTemplate = template;

UltraWebGrid1.Bands[0].CellClickAction = Infragistics.WebUI.UltraWebGrid.CellClickAction.CellSelect;

if(!IsPostBack)

{

UltraWebGrid1.DataSource = dsData.Tables[
"Dat"];this.DataBind();

}

}

 When page is first loaded, clickign on a button on the grid invokes the RowEdit template correctly, however on a postback clicking on the button again calls ClickCellButton function however it looks like editRow simply doesn't show the RowEdit template anymore.

Any ideas?

 

Thanks,

 

 

Parents
No Data
Reply
  • 28464
    posted

    Hello,

    This appears to me to be a page lifecyle events issue, I can suggest a few things which you may try.

    The first suggestion is to use the InitializeDataSource event of the grid and move your code there (both the declarative assigning of the row template and the databinding). TBecause the grid requires data at different points during the page lifecycle according to the features being used, there isn't one place where data can be bound.  Page_load may be late in other cases.  Because of the strict requirements the grid has on when it needs data, the InitializeDataSource event is how the Grid will request data.  In this event, you must assign the grid's datasource (and be sure if it's a dataset, it has data in it).  You don't need to call DataBind, just setting the datasource is enough in this event. Make sure you rebind in all cases, not only when Postback is false.

    The second suggestion you may try is to move the code fom Page_Load, to OnInit and rebind in all cases (not only when Page.IsPostBack is false).After postback, the grid needs to restore its state from ViewState, this happens between Init and Load, so setting datasource and row template there may work out better in postback scenarios.

Children