Adding Literals to newest updated grids

2 posts, 1 answers
  1. Kyle Butler
    Kyle Butler avatar
    26 posts
    Member since:
    Jun 2008

    Posted 07 Dec 2011 Link to this post

    I can't seem to get my old code for adding a literal to the new grid control I updated yesterday (in my case a message that customer 123 was deleted when done so). Is there a different way or something I'm missing? Here's the code:
    Private Sub DisplayMessage(text As String)
            grdList.Controls.AddAt(0, New LiteralControl(String.Format("<span style='color:red'>{0}</span>", text)))
        End Sub

    Thanks for any help in advanced!
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Dec 2011 Link to this post

    Hello Kyle,

    Try the following code.
    VB:
    Protected Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs)
        If TypeOf e.Item Is GridDataItem Then
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
            Dim cell As TableCell = DirectCast(item("UniqueName"), TableCell)
            Dim ltl As New Literal()
            ltl.ID = "Literal1"
            ltl.Text = "Text"
            cell.Controls.Add(ltl)
        End If
    End Sub

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