Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    click event in dynamically created template field

    i have made a template field in gridview at runtime dynamically by using a class MyTemplateField which is implementing ITemplate interface.

    In this field i have add a button by impleted method InstatiateIn of MyTemplateField class.

    but how can i bind my gridview on that button-click, i don't know.

  • #2
    New Coder
    Join Date
    Mar 2007
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well first you gotta add a click event handler to that button, depending on which language you're using, the way to do this may be different. I dont really know what your InstantiateIn method works, but I assume you have to declare the button before you put it in the template field, so when you declare the button:

    C#
    Code:
    Button btn = new Button;
    btn.Text = "Click Here";
    //rest of the button properties
    btn += new Button_Click();
    (my C# method might be a bit off, I havent done it too often for that)

    VB.Ne5
    Code:
    Dim btn As Button
    btn.Text = "Click Here"
    'rest of the properties
    AddHandler btn.Click, AddressOf Button_Click
    The your Button_Click would look like this:
    C#
    Code:
    protected void Button_Click(object sender, EventArgs e)
    {
      //do whatever needs to be done before binding the datagrid, then bind it  
      datagrid.DataBind();
    }
    VB.Net
    Code:
    Protected Sub Button_Click(sender As Object, e As EventArgs)
      'see above 
      datagrid.DataBind()
    End  Sub
    I hope that helps, if its not what you're looking for, post a bit more details and ill try to help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •