Attributes on Datagrid's button column ?

  • Thread starter Thread starter Hypo
  • Start date Start date
H

Hypo

I want to add some JS attributes on datagrid's button
column. I tried folowing:
for (int i=0; i < DataGrid1.Controls.Count; i++)
if (DataGrid1.Controls is
System.Web.UI.HtmlControls.HtmlInputButton)
((System.Web.UI.HtmlControls.HtmlInputButton)
DataGrid1.Controls).Attributes.Add("onclick", "return
confirm('Are you sure you want to delete this item ?')");

It doesnt work.
Anyone, please.... Thanks!
 
-----Original Message-----
You might find it better to use the FindControl method
to locate the button you

Yes, thats fine, but i realy need to iterate through
Button column controls.
Anyway, buttons cannot sem to be found using
DataGrid.FoundControl().
Result html code that datagrid produce, gives values to
those input button controls like DataGrid1:_ctl2:_ctl0,
DataGrid1:_ctl2:_ctl0, and so on, ... , but i cannot
find those controls from code using DataGrid1.FindControl
("DataGrid1:_ctl2:_ctl0") for example.

Maybe those controls are not yet created on server by
time when FindControl is called, or maybe im using wrong
approach.

Thanks for help
 
Back
Top