Why some web controls do not have ID property?

J

John Dalberg

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];
 
W

Wilco Bauwer

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).
 
J

John Dalberg

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
Martindap

Latest Threads

Top