Dynamic Control capture button click.
I have dynamically added controls using a Placeholder to a form. This form
is data driven thus I never know how many records will be retrieve. My form
looks like this
txtKey0=1111, txtBox0, txtDate0, btnEdit0
txtKey1=2323, txtBox1, txtDate1, btnEdit1
txtKey2=4343, txtBox2, txtDate2, btnEdit2
When I select a button I need to find out what my txtkey value is so that I
can pass it to a Querystring and display another page. Of course, currently
I only have one btnEdit_Click event which seems pretty lost. How do I get my
key values depending upon the button that I select. Or would I be better off
putting this in a datagrid control?
Re: Dynamic Control capture button click.
A datagrid, repeater or datalist may be a good choice. If you do not
use that, then you can set the button's CommandName and CommandArgument
properties. Instead of handling their click event, you should then
handle the Command event. All controls' Command event can have the same
event handler. Inside that event handler you can then extract the
information from the CommandName/CommandArgument properties to do your
In case you have problems related to dynamically loaded controls, you
may also want to take a look at
- Wilco Bauwer
Blog & Custom Controls @ http://wilcoding.xs4all.nl
|All times are GMT. The time now is 07:48 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.