我正在使用一个链接按钮显示Grid,如果我单击它,它将显示一个GridView就像一个对话框(Popup)。那就是Grid,
<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有一个Column包含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
}
答案 0 :(得分: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>