2015-09-14 53 views
1

後選擇的行我有一個用戶控制,以使從一個表,其中包含一個UpdatePanel的GridView不改變第一回發

<asp:UpdatePanel runat="server" ID="upSelection" UpdateMode="Conditional" ChildrenAsTriggers="false"> 
    <ContentTemplate> 
<asp:TextBox runat="server" ID="txtControlText" SkinID="M_Selection" ReadOnly="true"></asp:TextBox> 
    <asp:Button runat="server" ID="btnSelection" Text="..." CssClass="btnSelection" OnClick="btnSelection_Click" CausesValidation="false" /><asp:Panel runat="server" ID="popupSelection" CssClass="popup"> 
     <asp:UpdatePanel runat="server" ID="upSelectionPopup" UpdateMode="Conditional" class="updatePanel"> 
      <ContentTemplate> 
       <div class="popup-content"> 
        <asp:GridView ID="gvSelection" SelectedRowStyle-BackColor="#FFBCBC" runat="server" OnRowDataBound="gvSelection_RowDataBound"> 
        </asp:GridView> 
       </div> 
      </ContentTemplate> 
     </asp:UpdatePanel>   
       <asp:ImageButton runat="server" ID="btnSaveSelection" SkinID="Save" OnClick="btnSaveSelection_Click" CausesValidation="false" /></ContentTemplate></asp:UpdatePanel> 

在div popup-content內一個GridView單個選擇經由jquery的對話框中顯示時,我點擊btnSelection並且當我點擊btnSaveSelection時再次隱藏。 在彈出式關閉時,我使用選定的行信息更新文本框。

我使用綁定事件該行數據,使行選擇,其中突出所選行

protected void gvSelection_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    if (e.Row.RowType == DataControlRowType.DataRow) 
     e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink((GridView)sender, "Select$" + e.Row.RowIndex); 
} 

這工作我第一次打開彈出完美的罰款。從第二次,如果我以前選擇了一行並確認,會發生什麼情況是當我點擊一行時,我看不到新選中的行突出顯示。回發被執行,並且該行在服務器端被正確選擇,因爲在保存選擇時,我看到文本框被更新爲正確的值。問題在於客戶端不會呈現突出顯示更改的gridview。

請注意,如果我打開並關閉彈出窗口而未確認任何內容,則所有內容都可以正常工作,我會看到各個行在單擊時突出顯示。

這似乎是一個客戶端呈現與select事件本身無關的問題,因爲如果我啓用分頁,當有一個先前選擇的行時,當我點擊「下一個」按鈕時,我看不到新頁面。只有我從不確認任何事情,我才能看到其他頁面。

的讓人不安的事情是,如果我檢查那個被髮送到客戶端的響應的內容,當我點擊一排,裏面我看到正確的table,即tr與背景顏色是我點擊了一個。只是這不會呈現給客戶端!

我試着將事件從RowDataBound更改爲RowCreated;我嘗試將OnSelectedIndexChanged事件附加到gridview,並在代碼隱藏中強制執行upSelectionPopup.Update();,但是代碼中和運行時期間的所有內容都看起來正確,直到我應該在瀏覽器中看到新的gridview爲止,而我卻沒有。

任何想法?謝謝

回答

1

我認爲這是由於update panel。內容面板嘗試添加後

</ContentTemplate> 
      <Triggers> 
       <asp:PostBackTrigger ControlID="whicheverbuttonyouaredoing" /> 
      </Triggers> 
     </asp:UpdatePanel> 
+0

行選擇通過客戶端單擊完成,我不想要完整的回發 – Piddu