Hello!
I have a big problem with a very simple thing.
I have WebAsyncRefreshPanel, UltraWebGrid and EditRowTemplate. I need to set controls in template to some default values before open template window. (Now if user changes values in template and click Cancel this values will be there when user opens temlate again).
I will not describe all the way how I tried to do this. My solutions were comlicated and not perfect. May be you can offer simple way for this simple problem.
Thanks in advance.
Svetlana.
Hello,
The EditRowTemplate is designed to be able to automatically retrieve values from the row being edited and display the values in the editors of the template. If you want to calculate the values on your own, you need to handle the BeforeRowTemplateOpen clientside event of the grid. Have you tried this approach? Further, is the grid embedded in the WebAsyncRefereshPanel or do you have that placed in your template?
Hi! Thanks for your answer.
Yes I have such construction:
<webasyncrefreshpanel id="warpShiftTypes"> <ultrawebgrid id="m_grid"> <Bands> <Band> <RowEditTemplate> <My Control id="tplEditShiftType"> </RowEditTemplate> ..........
I have tried BeforeRowTemplateOpen event.
*Script function setDefaultColor is on template's .aspx page.
1 way:
*Here script function beforeShiftTypeTemplateOpen is registered from page's .aspx.cs file
****page.aspx.cs ****
protected void Page_Load( object sender, EventArgs e ) { m_grid.InitializeLayout += new InitializeLayoutEventHandler(InitializeLayout); m_grid.ClientEvents.BeforeRowTemplateOpenHandler = "beforeShiftTypeTemplateOpen";
}
protected void InitializeLayout(object sender, EventArgs e) { ShiftTypeTemplate template = new ShiftTypeTemplate(); template = (ShiftTypeTemplate)m_grid.Bands[0].RowEditItem.FindControl("tplEditShiftType"); string ddlColorID = template.DdlColorClientID; string divColorID = template.DivColorClientID; string script = "function beforeShiftTypeTemplateOpen() { "
+ String.Format("setDefaultColor('{0}', '{1}');", ddlColorID, divColorID) }";
warpShiftTypes.RegisterScript(script); //register script in UpdatePanel (simply writes script in HTML) }
Problem: I get error message because my controls in template have another IDs after async postback. But script already registered. Can you tell me how to register script in update panel properly (I want it to update after postback)
2 way:
*Here script function function beforeShiftTypeTemplateOpen is located on page's .aspx file
***page.aspx ***
function beforeShiftTypeTemplateOpen (ddlColorID, divColorID) { setDefaultColor(ddlColorID, divColorID); beforeRowTemplateOpen();}
protected void Page_Load( object sender, EventArgs e ) { m_grid.InitializeLayout += new InitializeLayoutEventHandler(InitializeLayout);
protected void InitializeLayout(object sender, EventArgs e) { ShiftTypeTemplate template = new ShiftTypeTemplate(); template = (ShiftTypeTemplate)m_grid.Bands[0].RowEditItem.FindControl("tplEditShiftType"); string ddlColorID = template.DdlColorClientID; string divColorID = template.DivColorClientID;
m_grid.ClientEvents.BeforeRowTemplateOpenHandler = String.Format("beforeShiftTypeTemplateOpen(\'{0}\', \'{1}\');", ddlColorID, divColorID);
Problem: It works but I get error message (because of inline javascript in BeforeRowTemplateOpenHandler):There is a problem with the event handler method: 'beforeShiftTypeTemplateOpen('ctl00_Content_dialog_gbTabs_tabs__ctl2_ctrlShiftTypes_m_grid_m_grid_ctl00_tplEditShiftType_ddlColor', 'ctl00_Content_dialog_gbTabs_tabs__ctl2_ctrlShiftTypes_m_grid_m_grid_ctl00_tplEditShiftType_divColor');'. Please check the method name's spelling.How can I overcome this?