How to set the Attributes of a control in Template

A

ad

Hi,
If a control in in web form, I can set the Attributes in Page_load event,
like:
Button1.Attributes["onclick"] = "return confirm('Are you sure?');";
But If the cotrol is in a DataGrid's template, if I use the same code
above, it will fail when compile (can't find MyButtonInTemplte)

How can I set thee attribute of a control in temple by code (not in the
..aspx)?
 
M

Mythran

ad said:
Hi,
If a control in in web form, I can set the Attributes in Page_load event,
like:
Button1.Attributes["onclick"] = "return confirm('Are you sure?');";
But If the cotrol is in a DataGrid's template, if I use the same code
above, it will fail when compile (can't find MyButtonInTemplte)

How can I set thee attribute of a control in temple by code (not in the
.aspx)?

Create an event handler for the ItemDataBound event of the DataGrid. From
here, find the control in the cells you want and update it directly.

Mythran
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top