2014-09-03 106 views
1

我有下一個要求:爲選擇不同的客戶端顯示多個選項 的DropDownList,一旦我選擇不同的客戶端並點擊一個按鈕,下拉列表 下面的網格應顯示我選擇的那些客戶端的報價, 如果我點擊一個特定的列彈出應該打開顯示該報價的詳細 。如何在更新面板中打開模式彈出窗口?

有型動物的場景:

1 .-如果我使用一個更新面板和它裏面我把下拉列表和網格,當我在那個特定的列彈出CLIC了 doesn't工作。

2.-如果我不使用更新面板一切都很好,除了 刷新網頁。

3.-如果我在選擇dropdownlist的某些內容之前加載數據網格,彈出窗口一直在工作,直到我在下拉列表中選擇了一些內容,這就是如何通過dropdownlist觸發的事件影響網格或彈出窗口這裏的一切都在更新面板中。

¿什麼建議我?

我有網頁的下面的代碼:

<div id="contentMain"> 
     <asp:UpdatePanel ID="updPanel" runat="server"> 
      <ContentTemplate> 
       <div style="margin-left: 190px; margin-bottom: -20px;"> 
        <asp:LinkButton runat="server" ID="LinkButton1" title="Seleccionar Clientes" OnClientClick="refrescarGrid() return false;"> 
       <span class="btnAceptar"></span> 
        </asp:LinkButton> 
       </div> 
       <table align="center"> 
        <tr style="text-align: center"> 
         <td class="labelTitle" style="background-color: #9AA8B3; border-radius: 3px;" colspan="1"> 
          Seleccionar Clientes 
         </td> 
        </tr> 
        <tr> 
         <td style="font-size: 12px"> 
          <cdis:ucDropDownListMultiple ID="ddlClients2" Requerido="false" LabelText="Clientes:" 
           runat="server" TextboxClassError="listaMultipleError chosen-choices" ContainerClass="ucTextbox" 
           TextboxClassNormal="chosen-choices" InputClassError="listaMultipleErrorInput" 
           InputClassNormal="chosen-choices" OpcionAgregar="false" ValidationGroup="vlg1" 
           Width="300px" MaxSelected="20" AutoPostBack="false" /> 
         </td> 
        </tr> 
       </table> 
       <div style=""> 
        <asp:LinkButton runat="server" ID="LinkButton2" title="Seleccionar Cotizaciones" 
         OnClick="btnGetSelectedQuotations"> 
       <span class="btnAceptar"></span> 
        </asp:LinkButton> 
       </div> 
       <asp:ImageButton ID="btnSession" ImageUrl="" runat="server" OnClick="btnSession_Click" 
        Style="display: none;" /> 
       <div class="subSection" align="center"> 
        <table align="center"> 
         <tr style="text-align: center"> 
          <td class="labelTitle" style="background-color: #9AA8B3; border-radius: 3px;" colspan="1"> 
           Cotizaciones Iniciales por Autorizar 
          </td> 
         </tr> 
         <tr> 
          <td> 
           <asp:ImageButton ID="ImageButton1" ImageUrl="" runat="server" OnClick="btnSession_Click" 
            Style="display: none;" /> 
          </td> 
         </tr> 
        </table> 
       </div> 
       <div align="center"> 
        <cc1:Grid ID="grdCatalogo" runat="server" AllowAddingRecords="false" Serialize="false" 
         ShowMultiPageGroupsInfo="false" AllowFiltering="false" AllowSorting="true" AllowGrouping="False" 
         AutoGenerateColumns="false" AllowPageSizeSelection="false" AllowColumnReordering="true" 
         AllowPaging="false" Width="100%" Height="100%" AllowRecordSelection="false" ShowFooter="false" 
         FolderLocalization="/Localization" Language="es" OnDataSourceNeeded="grdCatalogo_DataSourceNeeded"> 
         <ExportingSettings ExportAllPages="true" ExportGroupHeader="true" ColumnsToExport="" /> 
         <PagingSettings ShowRecordsCount="false" /> 
         <ScrollingSettings NumberOfFixedColumns="0" FixedColumnsPosition="Left" /> 
         <ClientSideEvents OnClientCallback="loadGridScripts" ExposeSender="true" /> 
         <Columns> 
          <cc1:Column DataField="DeseasAutorizar" HeaderText=" Desea Autorizar" ItemStyle-Wrap="false" 
           Width="109px" Wrap="true" HeaderAlign="center" Align="center"> 
           <TemplateSettings TemplateId="tplActionCheck" /> 
          </cc1:Column> 
          <cc1:Column HeaderText="Código" DataField="tQuotationClientCode" Wrap="true" HeaderAlign="center" 
           Width="100px"> 
          </cc1:Column> 
          <cc1:Column HeaderText="Nombre" DataField="tQuotationClientName" Wrap="true" HeaderAlign="center" 
           Width="248px"> 
          </cc1:Column> 
          <cc1:Column HeaderText="Número de Cotización" DataField="tQuotationQuotationNumber" 
           Wrap="true" HeaderAlign="center" Width="120px"> 
           <TemplateSettings TemplateId="tplIndividualQuotations" /> 
          </cc1:Column> 
          <cc1:Column HeaderText="Número de Solicitud" DataField="tQuotationRequestNumber" 
           Wrap="true" HeaderAlign="center" Width="120px"> 
           <TemplateSettings TemplateId="tplIndividualRequest" /> 
          </cc1:Column> 
          <cc1:Column HeaderText="Tipo de Trabajo" DataField="tQuotationWorkType" Wrap="true" 
           Width="250px" HeaderAlign="center"> 
          </cc1:Column> 
          <cc1:Column HeaderText="Código Producto del Cliente" DataField="tQuotationClientProductCode" 
           Wrap="true" Width="153px" HeaderAlign="center"> 
          </cc1:Column> 
          <cc1:Column HeaderText="Nombre del Trabajo" DataField="tQuotationWorkName" Wrap="true" 
           Width="240px" HeaderAlign="center"> 
          </cc1:Column> 
          <cc1:Column HeaderText="" DataField="tQuotationQuotationId" Visible="false"> 
          </cc1:Column> 
          <cc1:Column HeaderText="" DataField="tQuotationRequestId" Visible="false"> 
          </cc1:Column> 
         </Columns> 
         <Templates> 
          <cc1:GridTemplate runat="server" ID="tplActionCheck"> 
           <Template> 
            <asp:CheckBox runat="server" ID="chkClientImp" EnableViewState="true" /> 
           </Template> 
          </cc1:GridTemplate> 
          <cc1:GridTemplate runat="server" ID="tplIndividualRequest"> 
           <Template> 
            <a class='modal' href='<%# "catIndividualRequest.aspx?pRequestId=" + 1+ "&pTmp=1"%>' 
             title="Actualizar Usuario"> 
             <asp:Label ID="Label1" Text='<%#Container.DataItem["tQuotationRequestNumber"]%>' 
              runat="server" /> 
            </a> 
           </Template> 
          </cc1:GridTemplate> 
          <cc1:GridTemplate runat="server" ID="tplIndividualQuotations"> 
           <Template> 
            <a class='modal' href='<%# "catIndividualQuotation.aspx?pQuotationId=" + Container.DataItem["tQuotationQuotationId"] + "&pTmp=1"%>' 
             title="Actualizar Usuario"> 
             <asp:Label ID="Label1" Text='<%#Container.DataItem["tQuotationQuotationNumber"]%>' 
              runat="server" /> 
            </a> 
           </Template> 
          </cc1:GridTemplate> 
         </Templates> 
        </cc1:Grid> 
       </div> 
      </ContentTemplate> 
     </asp:UpdatePanel> 
    </div> 

代碼背後:

protected void grdCatalogo_DataSourceNeeded(object sender, GridDataSourceNeededEventArgs e) 
     { 
      int count = 0; 
      if (grdCatalogo.Rows != null) 
      { 
       foreach (GridRow row in grdCatalogo.Rows) 
       { 
        GridDataControlFieldCell cell = row.Cells[0] as GridDataControlFieldCell; 
        if (cell != null) 
        { 
         CheckBox asignar = cell.FindControl("chkClientImp") as CheckBox; 

         if (asignar.Checked) 
         { 
          DiccionarioAsignar.Add(count, asignar.Checked); 
         } 
        } 
        count++; 
       } 
      } 

      try 
      { 

       List<object> lst = new List<object>(); 
       if (ddlClients2.GetSelectedItems().Count > 0) 
       { 
        foreach (System.Web.UI.WebControls.ListItem li in ddlClients2.Items) 
        { 
         if (li.Selected == true) 
         { 
          foreach (object obj in QuotationBLL.Get_QuotationInfoCatalogById(Convert.ToInt32(li.Value))) 
          { 
           lst.Add(obj); 
          } 
         } 
        } 
       } 

       grdCatalogo.DataSource = lst; 
       grdCatalogo.DataBind(); 
       grdCatalogo.FolderStyle = "~/App_Themes/" + Page.Theme + "/styles/oboutgrid"; 
      } 
      catch (CDISException ex) 
      { 
       MostrarErrorGeneral(ex.ErrorMessage); 
       ErrorOboutGrid = ex.ErrorMessage; 
      } 
      catch (Exception exGeneral) 
      { 
       MostrarErrorGeneral("Ocurrió un error inesperado. Verifique la información ingresada y contacte con el encargado de la aplicación."); 
       ErrorOboutGrid = "Ocurrió un error inesperado. Contacte con el encargado de la aplicación."; 
      } 
     } 
+0

我已經這樣做過,但沒有下拉列表所以這裏的問題似乎被什麼東西涉及與多個選項的下拉列表。 – 2014-09-03 22:42:41

+0

由於Chrome最近禁用了「showModalDialog」支持,所以我會小心使用真正的模式對話框(而不是Lightbox或類似對象):http://blog.chromium.org/2014/07/disabling-showmodaldialog.html – 2014-09-03 23:10:16

回答

2

它看起來像你實際上到掛鉤聯繫「打開模態對話框」代碼在tplIndividualQuotations的基礎上通過JavaScript根據class="modal"

我相信你的代碼這樣做只會在頁面加載時觸發一次(使用類似jQuery $()方法或類似的東西)。

問題是,當UpdatePanel重新加載時,這段代碼不會再次運行,並將代碼掛接到已添加到頁面的新的<a>元素上。

當你使用你要去的UpdatePanel需要掛接到ASP.NET AJAX PageRequestManager

你需要一個方法添加到endRequest事件掛鉤是:

完成異步回發並將控件返回給瀏覽器後引發。

所以你會碰到這樣的:

<script type="text/javascript"> 
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(pageLoaded); 

    function pageLoaded(sender, args) { 
    //Code to hook up modal load here... 
    } 
</script> 
相關問題