簡體   English   中英

未觸發OnRowUpdating事件和TextBox_TextChanged事件

[英]OnRowUpdating event and TextBox_TextChanged Event not fired

我正在顯示帶有一個鏈接按鈕的網格,如果單擊該按鈕,它將顯示一個像對話框(Popup)的GridView。

<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的列。

<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
}

使用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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM