Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. ItemTemplate can't find a control in placeholder

ItemTemplate can't find a control in placeholder

Scheduled Pinned Locked Moved ASP.NET
helpdesignsysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mark_me
    wrote on last edited by
    #1

    Hi, i have a problem retrieving a control that has been added at runtime into the place holder... Please provide help...

    <telerik:GridTemplateColumn HeaderText="Description" SortExpression="ProductName" UniqueName="ProductName2">
    <HeaderStyle HorizontalAlign="center" />
    <ItemStyle HorizontalAlign="Left" Width="700px" />
    <ItemTemplate>
    <table style="border:0px;" >
    <tr >
    <td style="border:0px;">
    <asp:Label id = "lblProductDescription" runat = "server" Text = '<%# Eval("ProductName") %>'></asp:Label>
    </td>
    </tr>
    <tr >
    <td style="border:0px;" ID ="tdAttributes" runat = "server">
    <asp:PlaceHolder id = "placeHolderAttributes" runat = "server" Visible = "false"></asp:PlaceHolder>
    </td>
    </tr>
    </table>
    </ItemTemplate>
    </telerik:GridTemplateColumn>

    Control is added in ItemDataBound as. This code works,

    </pre>
    'htmltable,row and cells are declared
    Select Case controltype
    Case ControlType.TEXTBOX 'Constants declared
    Dim textBox As Telerik.Web.UI.RadTextBox = New Telerik.Web.UI.RadTextBox
    textBox.ID = "MYCONTROL"
    tableCell.Controls.Add(textBox )
    Case ControlType.TEXTAREA
    Dim textBox As Telerik.Web.UI.RadTextBox = New Telerik.Web.UI.RadTextBox
    textBox.ID = "MYCONTROL"
    tableCell.Controls.Add(textBox )
    Case GlobalControls.UCFormFields.FormFieldTypes.CHECKBOX
    Case GlobalControls.UCFormFields.FormFieldTypes.DROPDOWNLIST
    End Select
    thisHtmlTable.Rows.Insert(0, thisTableRow)
    thisTableRow.Cells.Add(tableCell)
    thisTableRow.Visible = True
    thisHtmlTable.Rows.Insert(thisHtmlTable.Rows.Count, thisTableRow)

    Dim placeHolder As PlaceHolder
    placeHolder = gridItem.FindControl("placeHolderAttributes")
    placeHolder.Controls.Add(thisHtmlTable)
    placeHolder.Visible = True

    In item command , i want to retrieve the control, i can switch between the controls if i retrieve the placeholder... my problem is that in itemcommand, i can retrieve the Placeholder but when i try pla

    J 1 Reply Last reply
    0
    • M mark_me

      Hi, i have a problem retrieving a control that has been added at runtime into the place holder... Please provide help...

      <telerik:GridTemplateColumn HeaderText="Description" SortExpression="ProductName" UniqueName="ProductName2">
      <HeaderStyle HorizontalAlign="center" />
      <ItemStyle HorizontalAlign="Left" Width="700px" />
      <ItemTemplate>
      <table style="border:0px;" >
      <tr >
      <td style="border:0px;">
      <asp:Label id = "lblProductDescription" runat = "server" Text = '<%# Eval("ProductName") %>'></asp:Label>
      </td>
      </tr>
      <tr >
      <td style="border:0px;" ID ="tdAttributes" runat = "server">
      <asp:PlaceHolder id = "placeHolderAttributes" runat = "server" Visible = "false"></asp:PlaceHolder>
      </td>
      </tr>
      </table>
      </ItemTemplate>
      </telerik:GridTemplateColumn>

      Control is added in ItemDataBound as. This code works,

      </pre>
      'htmltable,row and cells are declared
      Select Case controltype
      Case ControlType.TEXTBOX 'Constants declared
      Dim textBox As Telerik.Web.UI.RadTextBox = New Telerik.Web.UI.RadTextBox
      textBox.ID = "MYCONTROL"
      tableCell.Controls.Add(textBox )
      Case ControlType.TEXTAREA
      Dim textBox As Telerik.Web.UI.RadTextBox = New Telerik.Web.UI.RadTextBox
      textBox.ID = "MYCONTROL"
      tableCell.Controls.Add(textBox )
      Case GlobalControls.UCFormFields.FormFieldTypes.CHECKBOX
      Case GlobalControls.UCFormFields.FormFieldTypes.DROPDOWNLIST
      End Select
      thisHtmlTable.Rows.Insert(0, thisTableRow)
      thisTableRow.Cells.Add(tableCell)
      thisTableRow.Visible = True
      thisHtmlTable.Rows.Insert(thisHtmlTable.Rows.Count, thisTableRow)

      Dim placeHolder As PlaceHolder
      placeHolder = gridItem.FindControl("placeHolderAttributes")
      placeHolder.Controls.Add(thisHtmlTable)
      placeHolder.Visible = True

      In item command , i want to retrieve the control, i can switch between the controls if i retrieve the placeholder... my problem is that in itemcommand, i can retrieve the Placeholder but when i try pla

      J Offline
      J Offline
      Jamil Hallal
      wrote on last edited by
      #2

      Hi Mark, before the execution of the ItemCommand , you must redraw the grid as you are creating dynamic controls on ItemDataBound.

      Regards, Jamil

      M 1 Reply Last reply
      0
      • J Jamil Hallal

        Hi Mark, before the execution of the ItemCommand , you must redraw the grid as you are creating dynamic controls on ItemDataBound.

        Regards, Jamil

        M Offline
        M Offline
        mark_me
        wrote on last edited by
        #3

        Hi, Thanks for replying. I am not sure on how to redraw the grid. i mean, i am not sure on which event to use for creating the controls, so that the controls are available for itemcommand. Can u please provide a bit more detail. Thanks again. Mark

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups