0
我正在通過在ItemDataBound事件期間向其注入LinkButton來定製Telerik RadGrid上的組頭。按鈕呈現完美,但我無法讓它擊中任何事件處理程序。動態創建的LinkButton不會觸發任何事件
下面是創建按鈕的代碼:
Private Sub rgWorkRequestItemCosts_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgWorkRequestItemCosts.ItemDataBound
If TypeOf e.Item Is GridGroupHeaderItem Then
Dim oItem As GridGroupHeaderItem = DirectCast(e.Item, GridGroupHeaderItem)
Dim lnkAdd As New LinkButton()
lnkAdd.ID = "lnkAdd"
lnkAdd.CommandName = "CustomAddWorkRequestItemCost"
lnkAdd.CommandArgument = DirectCast(oItem.DataItem, DataRowView).Row("nWorkRequestItemID").ToString()
lnkAdd.Text = String.Format("<img style=""border:0px"" alt="""" width=""12"" src=""{0}"" /> Add new cost", ResolveUrl(String.Format("~/App_Themes/{0}/Grid/AddRecord.gif", Page.Theme)))
lnkAdd.Style("color") = "#000000"
lnkAdd.Style("text-decoration") = "none"
AddHandler lnkAdd.Click, AddressOf lnkAdd_Click
Dim tcPlaceholder As GridTableCell = DirectCast(oItem.Controls(1), GridTableCell)
Dim litText As New LiteralControl(String.Format(" {0}", tcPlaceholder.Text))
tcPlaceholder.Text = String.Empty
tcPlaceholder.Controls.Add(lnkAdd)
tcPlaceholder.Controls.Add(litText)
End If
End Sub
此代碼明確地增加了對LinkButton的處理程序,但處理程序從不打。我也嘗試過RadGrid(ItemCommand,ItemEvent)上的事件,但似乎沒有人受到影響。
有沒有人有任何其他事件的建議嘗試,或使其工作?
謝謝!
你可以cellclick事件,它可以爲它工作。只是檢查列的標題和傳遞行ID。 – 2010-04-15 10:53:23