Saturday, March 24, 2012

Why some web controls do not have ID property?


I am trying to attach a javascript to a ButtonColumn in each row in a
datagrid but the buttoncolumn doesn't have a ID property. Is there a way to
use a function similar to findcontrol where I find the buttoncolumns in
the code behind?
I am trying to avoid the syntax below because it's not dynamic.
WebControl button = (WebControl) e.Item.Cells[0].Controls[0];
John DalbergA ButtonColumn is not a web control. It is an object which represents
_every_ field in that column. Put differently: every field in a column
is based on a column (such as its style, the data it displays, etc).
You could either use a TemplateColumn and specify the ID for each
control yourself, or do what you already suggested (which is quite
common as far as I know).
On 17 Feb 2005 12:59:24 -0800, Wilco Bauwer wrote:

> A ButtonColumn is not a web control. It is an object which represents
> _every_ field in that column. Put differently: every field in a column
> is based on a column (such as its style, the data it displays, etc).
> You could either use a TemplateColumn and specify the ID for each
> control yourself, or do what you already suggested (which is quite
> common as far as I know).
System.Web.UI.WebControls.ButtonColumn implies it's a webcontrol.. no?
John Dalberg
No. Controls which derive from WebControl are considered to be
webcontrols.

0 comments:

Post a Comment