我有一個用於delete
和edit
按鈕的命令模板。GridView編輯按鈕導致異常
當我單擊edit
按鈕併爲每個字段填寫正確數據類型的數據時,這將工作得很好。
但是,當我填寫錯誤數據類型的數據到字段中時,會在網頁瀏覽器上觸發異常。我該如何糾正這一點,你們背後的任何代碼都可以提出建議,並把它放在哪裏?
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="ProductCode" DataSourceID="SqlProductmaster"
ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="ProductCode" HeaderText="ProductCode"
ReadOnly="True" SortExpression="ProductCode" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName"
SortExpression="ProductName" />
<asp:BoundField DataField="Category" HeaderText="Category"
SortExpression="Category" />
<asp:BoundField DataField="SellingPrice" HeaderText="SellingPrice"
SortExpression="SellingPrice" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity"
SortExpression="Quantity" />
<asp:BoundField DataField="BrandName" HeaderText="BrandName"
SortExpression="BrandName" />
<asp:BoundField DataField="ReOrderQty" HeaderText="ReOrderQty"
SortExpression="ReOrderQty" />
<asp:BoundField DataField="ReOrderLevel" HeaderText="ReOrderLevel"
SortExpression="ReOrderLevel" />
<asp:BoundField DataField="Ordered" HeaderText="Ordered"
SortExpression="Ordered" />
<asp:BoundField DataField="Allocated" HeaderText="Allocated"
SortExpression="Allocated" />
<asp:BoundField DataField="FreeQty" HeaderText="FreeQty"
SortExpression="FreeQty" />
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:Button ID="Update" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:Button ID="Cancel" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<ItemTemplate>
<asp:Button ID="edit" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Delete" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="false" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="False" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="False" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
請發送例外 –
什麼是例外名稱?也許你需要寫一個事件。 –
@Marco抱歉Marco,現在異常消失了,但是出現了其他問題。似乎更新按鈕不會觸發任何東西,當我click.cancel和刪除工作正常。奇怪的? –