Last post Jan 14, 2011 02:51 AM by Qin Dian Tang - MSFT
Jan 11, 2011 07:33 AM|ankur.nigam|LINK
I am writing a custom control and implementing ITemplate in it. The code that I am using can be reviewed at the following link: http://msdn.microsoft.com/en-us/library/ms178657.aspx
Under the Template field, I would only like to allow controls of specific type only, say LinkButton and TextBox. If any control(s) present inside Template is anything except LinkButton or TextBox, an error should be thrown.
I am wondering how can I check it programmatically inside custom control. The problem is that there is no collection available that lists all the controls that of Template (or may be I am not aware of it.)
Any snippet/pointers in this regard would be appreciated.
Jan 14, 2011 02:51 AM|Qin Dian Tang - MSFT|LINK
It can be only checked when you create the template dynamically. Then you can check Controls collection to see if the control in it is LinkButton or TextBox. Like you can get the control from the Template of GridView: GridView1.Rows.Controls[index].
You can loop the Controls collection from it.