This is a migrated thread and some comments may be shown as answers.

RadGrid inside ServerControl and LinkButton.Click ...

1 Answer 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephan Reisinger
Top achievements
Rank 1
Stephan Reisinger asked on 05 Dec 2013, 02:42 PM
Good Afternoon,

I had the idea of including a RadGrid control inside a custom server control ( reusable on various sites ) and everything works just peachy apart the .Click event of a LinkButton in a TemplateColumn that I can't seem to intercept !

The layout is as follows:

aspx
  asp:Panel
    MyControl
      telerik:RadGrid
        MasterTableView
          GridTemplateColumn
            LinkButton

The LinkButton is created on fly during the RadGrid.ItemDataBound event and added to the columns control collection via:


Dim o_LineDeleteItem As New LinkButton With {.Text = "Del", .ID = String.Format("Delete|" & __Item.DataItem("slc_ID").ToString), .CommandName = "DeleteLineItem", .CommandArgument = __Item.DataItem("slc_ID").ToString}
__Item("Options").Controls.Add(o_LineDeleteItem)

 
I have tried with/without AddHandler and whatnot, can't seem to get it to work.

The Panel is ajaxified via a RadAjaxManagerProxy and has a RadAjaxLoadingPanel that correctly shows when I click the LinkButton in the grid ... but for some reason I am unable to either get the RadGrid.ItemCommand or LinkButton.Click event to fire to actually do something when the button was clicked.

I tried if many different ways, but this being my first such implementation I most certainly miss something ( more or less ) important.

Any clues on this ?

PS: I looked thru the documentation and searched the www ... to no avail.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Dec 2013, 05:46 AM
Hi Stephan Reisinger ,

Please create the LinkButton inside the ItemCreated event of the RadGrid. ItemCreated should be hooked when you need to modify the controls inside a grid cell.

VB:
Protected Sub RadGrid1_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
  'Your Code
Dim o_LineDeleteItem As New LinkButton With {.Text = "Del", .ID = String.Format("Delete|" & __Item.DataItem("slc_ID").ToString), .CommandName = "DeleteLineItem", .CommandArgument = __Item.DataItem("slc_ID").ToString}
__Item("Options").Controls.Add(o_LineDeleteItem)
 'Add the Click event
  AddHandler o_LineDeleteItem.Click, AddressOf o_LineDeleteItem_Click
End Sub

Thanks,
Shinu
Tags
Grid
Asked by
Stephan Reisinger
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or