0
使用DyanamicData,我有一個標準的多對多表格,在插入一個新的獨特行時工作得很好。兩個父表的下拉列表顯示爲他們應該,並且行被正確插入。如何在插入過程中發生SqlException時檢索DynamicData DetailsView Viewstate?
但是,在一張桌子上,我有一個唯一索引,它引發了一個異常,我可以在OnInserted事件處理程序中捕獲它。然後,我可以向用戶發回一條友好的好消息,通知他們這個問題。發生該問題是因爲DetailsView丟失了視圖狀態,並且用戶爲DropDownLists選擇的值被重置爲頁面的默認值。
protected void DetailsDataSource_Inserted(object sender, LinqDataSourceStatusEventArgs e)
{
if (e.Exception != null && !e.ExceptionHandled)
{
msgPanel.Text = "Error Occurred"; // or some other friendly message
e.ExceptionHandled = true;
// e.Result == null, so I can't rebuild the user's input from here.
// What can be put where to get the user's input restored?
}
}
問題不清楚,或者沒有人有解決方案嗎?我不能成爲唯一有這個問題的人。 – drovani 2010-12-06 22:41:56