dotnet-practitioner
dotnet-practitioner

Reputation: 14148

vs2008 web express: detailsview can not hide new button

On details view, I would like to hide the new button.

On page load I have successfully done so by the following code:

dtvwMyProfile.Rows[5].Cells[0].Controls[2].Visible = false;

But how do I hide the New button when I hit cancel or update button after I am done editing.

The New button keeps showing up. How do I hide it completely from the screen.

In some event, the visible property keeps changing to true and how do i find out that event?

I want to be able to do it at run time instead of design time.

Upvotes: 0

Views: 293

Answers (2)

Eilon
Eilon

Reputation: 25704

Dynamically changing the properties of child controls created by the DetailsView is not recommended.

If the button is being created by the DetailsView itself then all you need to do is set AutoGenerateInsertButton to false and you can do that in Page_Load.

I do not recommend randomly selecting a page event and handling it. If you do that then chances are it will just break again when you change something else.

Upvotes: 1

Brian Mains
Brian Mains

Reputation: 50728

Maybe try to do that in the ModeChanged event handler, which fires after the mode changes... But can you ensure new is always at position 2? You may want to verify the button by its text or command name.

Upvotes: 0

Related Questions