Manipulating Grid column - Adding link button

2 posts, 0 answers
  1. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 05 Jan 2012 Link to this post

    I have radgrid with itemplate for every column like below
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="Vertical" Skin="Hay" PageSize="250"
          AllowSorting="True" AllowPaging="True" ShowGroupPanel="False" AutoGenerateColumns="false"
          Width="100%" >
          <PagerStyle Mode="Slider"></PagerStyle>
          <MasterTableView ShowGroupFooter="true" GroupsDefaultExpanded="False" HeaderStyle-HorizontalAlign="Center"
              GroupHeaderItemStyle-BackColor="white" GroupHeaderItemStyle-ForeColor="Black"
              GroupHeaderItemStyle-Font-Size="Medium" DataKeyNames="SkillID">
                          <telerik:GridGroupByField FieldName="SkillAreaId" HeaderText=" " />
                          <telerik:GridGroupByField FieldName="SkillArea" HeaderText=" " />
                          <telerik:GridGroupByField FieldName="SkillAreaId" HeaderText="" HeaderValueSeparator=" " />
                  <telerik:GridTemplateColumn  UniqueName="SkillID">
                              <%# Eval("SkillID")%>
                          <%# Eval("Skill")%>
                          None<br />
                          <asp:RadioButton ID="RadioButton1" runat="server" /></ItemTemplate>
                          Basic<br />
                          <asp:RadioButton ID="RadioButton2" runat="server" /></ItemTemplate>

    I  been trying to access each column in the grid to add a link button for each row with the same event attached to all the link button. But I am stuck at even getting the column value or adding link button to the column. I tried below,

    Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound
    If TypeOf e.Item Is GridDataItem Then
                Dim itm As GridDataItem = CType(e.Item, GridDataItem)
     itm("SkillId").Controls.Add(New LiteralControl("test"))
    End If

    But nothing works. I just simply want to get the value of the column first and embed a link button to the column and trigger a common event. Help me out. 
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Jan 2012 Link to this post


    Try the following code.
    Protected Sub RadGrid1_ItemCreated(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("SkillID"), TableCell)
            Dim btn As New LinkButton()
            btn.ID = "Link"
        End If
    End Sub

  3. DevCraft R3 2016 release webinar banner
Back to Top