2014年7月13日 星期日

[RESOLVED] Code not seeing button in formview itemtemplate


I have a formview and in it I have an asp button btnEdit. I need to set the enabled property in my on page load event, but my code does not see this button, why is it not declared if it's in a formview?


Can anyone suggest why and how I can fix this?


I'm simply doing this Me.btnEdit.Enabled = "False"



You need to use the FindControl() function.  Something like this...


Button btnEdit = (Button)FormView1.FindControl("btnEdit");
btnEdit.Enabled = false;

 


Matt



That did the trick


Much appreciated, Matt


沒有留言:

張貼留言