RadGrid with Dynamically added LinkButtons loosing buttons on filter.

2 posts, 0 answers
  1. Brandon
    Brandon avatar
    2 posts
    Member since:
    May 2016

    Posted 31 May Link to this post

    Hello,

    My customer has requested that we put link buttons into a specific field on a grid. The nature of the filed being that I need to have regular text followed by an unlimited number links means that I have to add my buttons dynamically. I have the text followed by links working proper upon the initial page load but something happens after the grid filter is applied. Once the grid filter is applied a post back occurs my method is still called to reformat the filed into it's final format however. Once the page loads the links are nowhere to be found and the grid cells display the text that is being converted into the buttons. Currently I am calling my logic to create the grid links on page load. I have to create the grid links in load because if I do it any later than that then my link buttons no longer function properly. Some help would be greatly appreciated. Thanks in advance below are some of my code snippets.

    -Brandon

     

    RadGrid Load Method

    1.Private Sub RadGridResults_Load(sender As Object, e As EventArgs) Handles RadGridResults.Load
    2.     For Each Item As GridItem In RadGridResults.MasterTableView.Items
    3.          CreateGridLinks(Item)
    4.     Next
    5.End Sub

    Create Grid Links Method (Simplified From Original)

    01.Private Sub CreateGridLinks(item As GridItem)
    02.    If TypeOf item Is Telerik.Web.UI.GridDataItem Then
    03.        Dim dataItem As Telerik.Web.UI.GridDataItem = CType(item, Telerik.Web.UI.GridDataItem)
    04.        For Each cell As TableCell In item.Cells
    05.            Dim Issues() As String = cell.Text.Split(";"c)
    06.            If Issues.Length > 1 AndAlso cell.Text <> " " Then
    07.                Dim CellText As String = Issues(0) + " "
    08.                Dim CellId As String = ""
    09.                Dim IssueAppealType As String = ""
    10.                Dim IssueAppealId As String = ""
    11.                For i As Integer = 1 To _issues.Length - 1
    12.                    If i = 1 Then
    13.                        cell.Controls.Add(New LiteralControl(CellText))
    14.                    End If
    15.                    If _issues(i).Trim.Split(":"c).Length > 1 Then
    16.                        Dim IssueAppealButton As New LinkButton()
    17.                        CellId = _issues(i).Trim.Replace(":", "")
    18. 
    19.                        Dim IssueAppealArray = _issues(i).Trim.Split(":"c)
    20.                        IssueAppealType = IssueAppealArray(0)
    21.                        IssueAppealId = IssueAppealArray(1)
    22.                        IssueAppealButton.Text = IssueAppealId
    23.                        cntrlCount += 1
    24.                        IssueAppealButton.ID = "LinkButton" + CellId + cntrlCount.ToString
    25.                         
    26.                        AddHandler IssueAppealButton.Click, Sub(send, evt) HandleIssueLinkClick(IssueAppealId, IssueAppealType)
    27. 
    28.                        cell.Controls.Add(IssueAppealButton)
    29.                        cell.Controls.Add(New LiteralControl(" "))
    30.                    End If
    31.                Next
    32. 
    33.            End If
    34.        Next
    35.    End If
    36.End Sub

  2. Brandon
    Brandon avatar
    2 posts
    Member since:
    May 2016

    Posted 01 Jun in reply to Brandon Link to this post

    Since posting this, I discovered that our team had access to an account with priority support. I have re-posted under that account. 

    Here is the link:

    http://www.telerik.com/forums/radgrid-with-dynamically-added-linkbuttons-loosing-buttons-on-filter-172ca9a04e4b#T0ux-fy1kkaxwO2VJkuuDg

     

    Please post any replies there.

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top