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?
Hello.
First time I have such id - UltraWebGrid1$ctl00$Control1, but when I click OK in temlate it is the update panel post back. And after it I have such id - UltraWebGrid1$ctl04$Control1(Another id!). So I can not use hard coded ids. That's why I need to write beforeRowTemplateOpen() in the event handler - I need to put correct Ids in it. Could you please make an example for my problem - and you will see what I'm talking about.
I've tried this and I get the same Id everytime the grid posts back inside the WARP.
What version of NetAdvantage including the build number are you using? What version CLR?
And what exactly is the control you have inside the template? Make sure nothing is changing when you implement your code.
I use NetAdvantage for .NET 2008 vol. 2 CLR 3.5
Version: 8.2.20082.1000
My template control has such structure:
<asp:Panel > <table> <tr> <td> <Controls:TextBox ID="tbShiftTypeName" runat="server" columnKey="Name" Width="100%" /> </td> </tr> <tr> <td> <Controls:DropDownList ID="ddlColor" runat="server" columnKey="ColorName" /> </td> </tr> <tr> <td> <div id="divColor" style="width: 100%; height: 3px; padding: 0px;" runat="server" columnKey="Color"/> </td> </tr> </table> <div > <input id="OkBtn" /> <input id="CancelBtn"/> </div></asp:Panel> And I need ddlColor and divColor to be fill with some default values.
But problem is : they have another Ids after WARP postback.
Ok, there seems to be some issues with the 8.2 release build. I cannot get a clientside event to trigger while the grid is inside the WARP. I don't know if you experienced this issue. However, I'ved tried this with an 8.3 release build and my events trigger correctly. I was able to get reference to the controls inside your user control everytime, using a hardcoded id, even after the grid updates:
I am not sure if your issue is caused by the 8.2 build but I cannot test it because of the issue I mentioned, which is most likely a bug. You should test this in the latest hotfix of 8.2 or upgrade to the 8.3 version. Further, you can contact developer support to verify that your issue is caused by a bug. I have searched the current known issues and did not find anything on this.
Dear Duc, I have fixed my problem with another way. Thanks for your answers. Good bye.