View Full Version : click event in dynamically created template field
05-31-2007, 05:30 PM
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.
06-03-2007, 03:40 PM
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:
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)
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:
protected void Button_Click(object sender, EventArgs e)
//do whatever needs to be done before binding the datagrid, then bind it
Protected Sub Button_Click(sender As Object, e As EventArgs)
I hope that helps, if its not what you're looking for, post a bit more details and ill try to help
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.