Adding attributes to DataGrid Items at runtime

handsofrain

New Member
I have a DataGrid. One column has datadependent buttons and I am trying to add an 'onclick' attribute at runtime, is this possible?<BR><BR>How do you link up to the HtmlTextWriter to get the attribute added? I am going round in circles with these classes.<BR><BR>I want something like this:<BR><BR>foreach (DataGridItem item in myDataGrid.Items)<BR>{ <BR> item.Cells[2].Attributes.AddAttributes(HtmlTextWriter)["onclick"] = "javascript:window.location.href=http://aspmessageboard.com/archive/index.php/'~uploads/some.doc';";<BR>}<BR><BR>Can anyone help me out?I have responded to a similar question here.<BR><BR>http://www.aspmessageboard.com/forum/aspplus.asp?M=370092&F=36&P=1<BR><BR>hth<BR>mattThanks Matt I did see that at first I thought it would help but unfortunately the Event I am trying to raise (on the client) is the onclick event of the button in the grid rather that the cell itself. I need to either raise an event on a hyperlink to a new target or raise an event on a command button to open a new window. The command handler runs on the server so I can't open the window there, and when I try adding the button onlick event with a javascript function and parameters I get compilation errors.
 
Back
Top