1
在一個ASP.Net VB.Net代碼隱藏文件中,您能告訴我什麼事件觸發我可以用來捕獲用戶在DetailsView顯示空白項目(如DropDownLists,TextBoxes等)時點擊DetailsView的「New」按鈕?當用戶點擊ASP.Net的「新建」按鈕時觸發的事件DetailsView
我需要使用此事件處理程序來預先選擇從變量中獲取的DropDownList中的值。
在一個ASP.Net VB.Net代碼隱藏文件中,您能告訴我什麼事件觸發我可以用來捕獲用戶在DetailsView顯示空白項目(如DropDownLists,TextBoxes等)時點擊DetailsView的「New」按鈕?當用戶點擊ASP.Net的「新建」按鈕時觸發的事件DetailsView
我需要使用此事件處理程序來預先選擇從變量中獲取的DropDownList中的值。
嘗試ItemCommand事件。這是如何使用它。我只知道C#,但我認爲你可以掌握它。背後
代碼:
protected void DetailsView_ItemCommand(object sender, DetailsViewCommandEventArgs e)
{
if (e.CommandName == "New")
{
// Your code here
}
}
標記:
<asp:DetailsView ID="DetailsView" runat="server" OnItemCommand="DetailsView_ItemCommand" ...
感謝您的答覆。我會嘗試這個事件,並讓你知道它我工作。 –
我發現當點擊「插入」按鈕時,一個很好。你知道哪一個適合「新建」按鈕嗎? –
使用ItemCommand是要走的路。謝謝。我試圖讓DropDownList使用下面的代碼選擇值,但列表仍然沒有顯示數據。你能告訴我額外需要的編碼來使它起作用嗎? Case「New」 Dim drpValue As DropDownList drpValue = DetailsView.FindControl(「DropDownListClass」) drpValue.SelectedValue = StrListValueToSelect –