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. linkbutton inside custom ItemTemplate

linkbutton inside custom ItemTemplate

Scheduled Pinned Locked Moved ASP.NET
designdockerquestion
2 Posts 1 Posters 1 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.
  • A Offline
    A Offline
    ake_krakbar
    wrote on last edited by
    #1

    Hello folks! I have a linkbutton inside a custom ItemTemplate that is used in a DataGrid. My prob is that the method delegated to the click-event never gets fired. Funny thing is - the method delegated to the DataBinding event works just fine. What am i doing wrong? Well, heres the (relevant parts of the) code: public void InstantiateIn(System.Web.UI.Control container) { switch(templateType) { case ListItemType.Header: case ListItemType.Item: case ListItemType.EditItem: LinkButton lb = new LinkButton(); lb.ID = "DeleteLink"; lb.Text = "Delete"; lb.Click += new EventHandler(this.lb_Click); lb.DataBinding += new EventHandler(this.OnDataBinding); container.Controls.Add(lb); break; } } // Doesn´t work at all.... public void lb_Click(object sender, EventArgs e) { // This never happens... throw new Exception(); } // Works just fine... public void OnDataBinding(object sender, EventArgs e) { LinkButton lb = (LinkButton)sender; DataGridItem container = (DataGridItem) lb.NamingContainer; lb.ToolTip = "Delete " + ((DataRowView) container.DataItem) ["FileName"].ToString(); }

    A 1 Reply Last reply
    0
    • A ake_krakbar

      Hello folks! I have a linkbutton inside a custom ItemTemplate that is used in a DataGrid. My prob is that the method delegated to the click-event never gets fired. Funny thing is - the method delegated to the DataBinding event works just fine. What am i doing wrong? Well, heres the (relevant parts of the) code: public void InstantiateIn(System.Web.UI.Control container) { switch(templateType) { case ListItemType.Header: case ListItemType.Item: case ListItemType.EditItem: LinkButton lb = new LinkButton(); lb.ID = "DeleteLink"; lb.Text = "Delete"; lb.Click += new EventHandler(this.lb_Click); lb.DataBinding += new EventHandler(this.OnDataBinding); container.Controls.Add(lb); break; } } // Doesn´t work at all.... public void lb_Click(object sender, EventArgs e) { // This never happens... throw new Exception(); } // Works just fine... public void OnDataBinding(object sender, EventArgs e) { LinkButton lb = (LinkButton)sender; DataGridItem container = (DataGridItem) lb.NamingContainer; lb.ToolTip = "Delete " + ((DataRowView) container.DataItem) ["FileName"].ToString(); }

      A Offline
      A Offline
      ake_krakbar
      wrote on last edited by
      #2

      problem solved. The columns where created too late in the control life cycle.

      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