我有设置为 DefaultMode="Edit" 的 asp:DetailsView,在此我有以下命令按钮
<asp:CommandField HeaderText="Action" ShowEditButton="True" ShowInsertButton="true" UpdateText="Save Changes" ShowCancelButton="true" ButtonType="Button" ControlStyle-CssClass = "button" />
问题是当我单击“保存更改”更新按钮时,它没有触发 ItemCommand 事件。
<asp:DetailsView ID="dvPerson" runat="server"
DataKeyNames="PersonID"
AutoGenerateRows="False" CellPadding="4" Width="1000"
ForeColor="#333333" GridLines="None" DefaultMode="Edit" Visible="False">
<PagerStyle BackColor="#949EAA" HorizontalAlign="Center" />
<Fields>
<asp:BoundField DataField="Phone" HeaderText="Phone"
SortExpression="Phone" Visible="true" ReadOnly="true"
ItemStyle-VerticalAlign="Top" />
<asp:BoundField DataField="Email" HeaderText="Email"
SortExpression="Email" Visible="true" ReadOnly="true"
ItemStyle-VerticalAlign="Top" />
<asp:TemplateField HeaderText="Primary Manager Contact"
ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Center">
<EditItemTemplate>
<asp:CheckBox runat="server" ID="cbxPrimaryManagerContact" Checked='<%# IsPrimaryMC(Eval("PersonID")) %>' Enabled="true" /></EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Training Assignments"
ItemStyle-VerticalAlign="Top">
<EditItemTemplate>
<asp:Label ID="lblTraining" runat="server" Text='<%# getTraining(Eval("PersonID")) %>' /><p> </p>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Job Roles"
ItemStyle-VerticalAlign="Top">
<EditItemTemplate>
<asp:CheckBoxList ID="lbxJobRoles" runat="server" DataSourceID="sqlJobRole" DataValueField="JobRoleID" DataTextField="JobRole" RepeatColumns="3" RepeatDirection="Horizontal" RepeatLayout="Table" CellPadding="2" CellSpacing="2" Width="1000" CssClass="the300" /><p> </p>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Attributes">
<EditItemTemplate>
<asp:CheckBoxList ID="cblAttributes" runat="server" DataSourceID="sqlAttributes" DataValueField="AttributeID" DataTextField="AttributeName" RepeatColumns="3" RepeatDirection="Horizontal" RepeatLayout="Table" CellPadding="2" CellSpacing="2" Width="1000" CssClass="the300" /></EditItemTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Action" ShowEditButton="True" ShowInsertButton="true" UpdateText="Save Changes" ShowCancelButton="true" ButtonType="Button" ControlStyle-CssClass = "button" />
</Fields>
</asp:DetailsView>