2017-04-04 38 views
0

我顯示一個鏈接按鈕網格,如果我點擊的是,它會顯示類似對話框(彈出)一個GridView。那電網是,OnRowUpdating事件和TextBox_TextChanged事件不會觸發

<asp:GridView ID="HistoryGrid" runat="server" AutoGenerateColumns="false" AllowSorting="True" 
     CellPadding="4" ForeColor="Black" AllowPaging="True" Font-Size="9pt" BackColor="White" 
     BorderColor="#DEDFDE" Width="100%" BorderWidth="1px" GridLines="Vertical" PageSize="10" 
     OnRowEditing="HistoryGrid_RowEditing" OnRowCancelingEdit="HistoryGrid_RowCancelingEdit" OnRowUpdating="HistoryGrid_RowUpdating" 
     OnRowUpdated="HistoryGrid_RowUpdated" OnRowDataBound="HistoryGrid_RowDataBound" > 

和HistoryGrid有一個包含TextBox的Column。

<Columns> 
     <asp:TemplateField><EditItemTemplate> 
       <asp:TextBox ID="DateTxt" CssClass="datepick" runat="server" AutoPostBack="true" OnTextChanged="DateTxt_TextChanged" Font-Size="8.3pt" ></asp:TextBox> 
       </EditItemTemplate></asp:TemplateField> 

現在的問題是TextBox_TextChanged事件和HistoryGrid_RowUpdating事件不會觸發。

代碼隱藏

protected void DateTxt_TextChanged(object sender, EventArgs e) 
{ 
//code 
} 

protected void HistoryGrid_RowUpdating(object sender, GridViewUpdateEventArgs e) 
{ 
//code 
} 
+0

檢查''AutoEventWireup在你的頁面指令真實。 – Arshad

+0

你已經是真的 – user7415073

回答

0

使用ItemTemplate而不是EditItemTemplate

<asp:TemplateField> 
    <ItemTemplate> 
     <asp:TextBox ID="DateTxt" CssClass="datepick" runat="server" AutoPostBack="true" OnTextChanged="DateTxt_TextChanged" Font-Size="8.3pt" ></asp:TextBox> 
    </ItemTemplate> 
</asp:TemplateField> 
+0

謝謝你的回答。無論如何,如果我更改了TextBox中的文本,GridView(Popup)已關閉,並且事件未被觸發 – user7415073

+0

您可以參考http://www.dotnetfunda.com/codes/show/3026/textbox-change-event -inside-gridview – Arshad

+0

我認爲你需要一個更新面板 – Arshad