Hi!
I have an Accordion on my page. In one AccordionPane, i have an UpdatePanel containing a GridView and a button under. When i try to access my gridview in the code-behind, i encounter a problem. The trigger of my button doesn't work, the method associated with my button isn't called. If i click a second time and the button, it postback my page and i lose all the data and the page. if i click a third time, the trigger associated with the button finally works.
I only get this problem when i try to access my GridView in my page.
I add my code and underlined the line which causes the problem, i remove it everythin works fine
aspx file:
<asp:UpdatePanelID="UpdatePanelGridStartSecurities"runat="server"UpdateMode="Conditional"ChildrenAsTriggers="false">
<ContentTemplate>
<divclass="ContentPaneDetails">
<%-- GridView : Supports de depart--%>
<divclass="ContentPaneElement">
<asp:GridViewID="GridViewGainOption_StartSecurities"runat="server"AutoGenerateColumns="false"BackColor="White"
BorderStyle="None"><Columns>
<%-- Inclure --%><asp:TemplateField>
<HeaderTemplate>
<labelid="LbGainOption_Include">
Include
</label>
</HeaderTemplate>
<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>
<ItemTemplate>
<asp:RadioButtonID="GainOption_Include"runat="server"BackColor="ActiveCaptionText"GroupName="IncludeExclude"
Checked='<%# ((bool)DataBinder.Eval(Container.DataItem, "IsExcluded"))?false:true %>'/>
</ItemTemplate>
<ItemStyleBorderColor="Black"BorderWidth="1px"HorizontalAlign="Center"/></asp:TemplateField>
<%-- Exclure --%>
<asp:TemplateField>
<HeaderTemplate>
<labelid="LbGainOption_Exclude">
Exclude
</label>
</HeaderTemplate>
<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>
<ItemTemplate>
<asp:RadioButtonID="GainOption_Exclude"runat="server"BackColor="ActiveCaptionText"GroupName="IncludeExclude"
Checked='<%# DataBinder.Eval(Container.DataItem, "IsExcluded") %>'/>
</ItemTemplate>
<ItemStyleBorderColor="Black"BorderWidth="1px"HorizontalAlign="Center"/>
</asp:TemplateField><%-- Valeur mobilière --%>
<asp:TemplateField>
<HeaderTemplate>
<labelid="LbGainOption_SecurityName">
Valeur mobilière
</label>
</HeaderTemplate>
<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>
<ItemTemplate>
<asp:TextBoxID="GainOption_SecurityName"runat="server"BorderStyle="None"Text='<%# GetSecurityName(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "SecurityId"))) %>'></asp:TextBox>
</ItemTemplate>
<ItemStyleBorderColor="Black"BorderWidth="1px"/>
</asp:TemplateField>
<%-- Isin Code --%>
<asp:TemplateField>
<HeaderTemplate>
<labelid="GainOption_IsinCode">
Isin
</label>
</HeaderTemplate>
<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>
<ItemTemplate>
<asp:TextBoxID="GainOption_IsinCode"runat="server"BorderStyle="None"Text='<%# GetIsinCode(Convert.ToInt32(DataBinder.Eval(Container.DataItem, "SecurityId"))) %>'></asp:TextBox>
</ItemTemplate>
<ItemStyleBorderColor="Black"BorderWidth="1px"/>
</asp:TemplateField>
<%-- Seuil --%>
<asp:TemplateField>
<HeaderTemplate>
<labelid="LbGainOption_Threshold">
Seuil %
</label>
</HeaderTemplate>
<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>
<ItemTemplate>
<asp:TextBoxID="GainOption_Threshold"runat="server"BorderStyle="None"Text='<%# DataBinder.Eval(Container.DataItem, "TriggerringThreshold") %>'></asp:TextBox>
</ItemTemplate>
<ItemStyleBorderColor="Black"BorderWidth="1px"/>
</asp:TemplateField>
<%-- Supprimer --%>
<asp:TemplateField>
<HeaderTemplate></HeaderTemplate>
<HeaderStyleBackColor="#D5DAE0"BorderStyle="None"/>
<ItemTemplate>
<asp:LinkButtonID="GainOption_Delete"runat="server"CommandName="Delete">Supprimer</asp:LinkButton>
</ItemTemplate>
<ItemStyleBackColor="#D5DAE0"BorderStyle="None"/></asp:TemplateField>
</Columns></asp:GridView>
</div>
</div>
<divclass="ContentPaneDetails">
<divclass="ContentPaneElement">
<%-- Ajouter un nouveau support de départ --%><asp:LinkButtonID="GainOption_AddStartSecurity"runat="server"Text="Ajouter une valeur"OnClick="GainOption_AddStartSecurity_Click">
</asp:LinkButton>
<br/>
<%-- Nom du support --%>
<asp:LabelID="LbGainOption_StartSecurityName"runat="server"Visible="false"Text="Valeur moblière :"></asp:Label>
<asp:TextBoxID="GainOption_StartSecurityName"runat="server"Visible="false"></asp:TextBox><asp:ImageButtonID="ImgGainOption_StartSecurityName"runat="server"ImageUrl="~/Images/Directory.gif"Visible="false"/>
<ajaxToolkit:AutoCompleteExtenderID="AutoCompleteGainOption_StartSecurityName"runat="server"TargetControlID="GainOption_StartSecurityName"
ServicePath="WebServices/AutoComplete.asmx"ServiceMethod="GetSecuritiesListByLongName"CompletionSetCount="3"MinimumPrefixLength="3"
CompletionListCssClass="autocomplete_completionListElement"CompletionListItemCssClass="autocomplete_listItem"CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"UseKeyValuePairs="true"
KeyHiddenFieldID="HiddenModify_SecurityId">
</ajaxToolkit:AutoCompleteExtender>
<%-- Isin du support --%>
<asp:LabelID="LbGainOption_StartIsinCode"runat="server"Visible="false"Text="Isin : "></asp:Label>
<asp:TextBoxID="GainOption_StartIsinCode"runat="server"Visible="false"></asp:TextBox><asp:ImageButtonID="ImgGainOption_StartIsinCode"runat="server"ImageUrl="~/Images/Directory.gif"Visible="false"/>
<ajaxToolkit:AutoCompleteExtenderID="AutoCompleteGainOption_StartIsinCode"runat="server"TargetControlID="GainOption_StartIsinCode"
ServicePath="WebServices/AutoComplete.asmx"ServiceMethod="GetSecuritiesListByIsinCode"CompletionSetCount="3"MinimumPrefixLength="3"
CompletionListCssClass="autocomplete_completionListElement"CompletionListItemCssClass="autocomplete_listItem"CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"UseKeyValuePairs="true"
KeyHiddenFieldID="HiddenModify_SecurityId">
</ajaxToolkit:AutoCompleteExtender>
<%-- Seuil du support --%>
<asp:LabelID="LbGainOption_StartThreshold"runat="server"Visible="false"Text="Seuil : "></asp:Label>
<asp:TextBoxID="GainOption_StartThreshold"runat="server"Visible="false"></asp:TextBox>
<%-- Insert --%>
<asp:LinkButtonID="InsertGainOption_StartSecurity"runat="server"Visible="false"Text="Insert"OnClick="InsertFromSecurity_Click"></asp:LinkButton>
</div>
<divclass="Clear">
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTriggerControlID="GainOption_AddStartSecurity"EventName="Click"/>
<asp:AsyncPostBackTriggerControlID="InsertGainOption_StartSecurity"EventName="Click"/>
</Triggers></asp:UpdatePanel>
cs file:
protectedvoid Page_Load(object sender,EventArgs e){
if (IsPostBack ==false){
HiddenModify_NavigationMode.Value ="1";//HiddenModify_NavigationMode.Value = "2";
//HiddenModify_MonitoringMandateId.Value = "7";
LogicMonitoringMandates monitorings =LogicMonitoringMandates.getInstance();LogicGainMandateOptions gainOptions =LogicGainMandateOptions.getInstance();
LogicLossMandateOptions lossOptions =LogicLossMandateOptions.getInstance();LogicSellMandateOptionDetails sellDetails =LogicSellMandateOptionDetails.getInstance();
LogicBuyMandateOptionDetails buyDetails =LogicBuyMandateOptionDetails.getInstance();LogicPortfolios portfolios =LogicPortfolios.getInstance();
LogicSecurities securities =LogicSecurities.getInstance();LogicPortfolioPositions positions =LogicPortfolioPositions.getInstance();
LogicPortfolioPositionDetails details =LogicPortfolioPositionDetails.getInstance();securities.GetSecurities();
if (HiddenModify_NavigationMode.Value =="1"){
/*RadioButton gainOption_AutomaticPerimeter = (RadioButton)AccordionPaneGainOption.FindControl("GainOption_AutomaticPerimeter");
RadioButton gainOption_00007Threshold = (RadioButton)AccordionPaneGainOption.FindControl("GainOption_00007Threshold");
gainOption_AutomaticPerimeter.Checked = true;
gainOption_00007Threshold.Checked = true;
*/}
if (HiddenModify_NavigationMode.Value =="2"){
int l_intMonitoringMandateId =Convert.ToInt32(HiddenModify_MonitoringMandateId.Value);
monitorings.GetMonitoringMandateByMonitoringMandateId(l_intMonitoringMandateId);
gainOptions.GetMandateOptionsByMonitoringMandateId(l_intMonitoringMandateId);
HiddenModify_GainMandateOptionId.Value =Convert.ToString(gainOptions.GetMandateOptionFromIndex(0).MandateOptionId);GridView gridViewGainOption_StartSecurities = (GridView)AccordionPaneGainOption.FindControl("GridViewGainOption_StartSecurities");
The problem comes if I add the line above
//sellDetails.GetMandateOptionDetailsByMandateOptionId(Convert.ToInt32(HiddenModify_GainMandateOptionId.Value));
//gridViewGainOption_StartSecurities.DataSource = sellDetails.TABLE;
//gridViewGainOption_StartSecurities.DataBind();
AccordionPaneSignaletique_DataBind();
AccordionPaneGainOption_DataBind();
}
}
}
Does anyone know what i can do? Can i add the trigger of the updatePanel in the code behind in the pageload method ?
Thanks in advance,
I've been looking for this problem for all my weekend and i found what was the problem!!!!!!!
The problem comes from the Accordion component, during the Page_Load, the Accordion and the child component doesn't exists, but in my case i didn't get any error of "not found controls".
I found a fix on this page :
http://couldbedone.blogspot.com/2007/07/what-wrong-with-accordion-control.html
Thanks a lot to this guy!
i just added Accordion.FindControl("nothing") on a Page_Init and it works great now!
No comments:
Post a Comment