This is a migrated thread and some comments may be shown as answers.

Hidding "InitInsert" button when in edit mode

3 Answers 81 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Pako
Top achievements
Rank 1
Pako asked on 15 Apr 2011, 10:55 AM

Hi,

I'm trying to accomplish this: I need to hide my "Add own content" buttons when user enters Insert mode. To handle this, I subscribed ItemCommand event and check if CommandName is "InitInsert". If is, I set EventSource element visibility to false. That works great.

What's giving me hard time is EmptyDataTemplate. I placed my "Add own content" button in this template, but then after clicking it, layout changes, so of course setting visibility of this button to false have no meaning. I figured out, that I could handle LayoutCreated event and then find this button and hide it. There I encountered another problem: how to find out, whether I'm in Insert mode or not? InsertItem property of ListView is null, when I know that I entered insert mode. I looked through other properties and cannot seem to find out how to verify mode in which ListView is.

My question are:

1. How can I find out whether I'm in insert mode or not?

2. Is there any other way I can hide "add own content' button when in insert mode?

Thanks in advance,

Pako

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 20 Apr 2011, 01:46 PM
Hi Pako,

Check how the "Add new product" is displayed fonditionally in this demo and see if you can use the same approach.
And to find a control in RadListView, you can try using the FindControl() method. For more information on how to access conrols in RadListView, refer to this topic.

All the best,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Pako
Top achievements
Rank 1
answered on 20 Apr 2011, 02:15 PM

Like I said, for some reason InsertItem is nothing when InitInsert command is called (at least when LayoutCreated event is raised), so I cannot use this approach. InsertItemPosition also is None at this moment.

I used workaround for this issue, using attributes collection of list view to remember whether listview is in Insert mode or not, but I'm aware, that this is not the right approach and would like to change it to something like this demo showed.

I hoped, that maybe you know something about RadListView that's causing InserItem to be null when InitInsert command is called.

0
Iana Tsolova
Telerik team
answered on 26 Apr 2011, 10:29 AM
Hello Pako,

InitInsertCommand is fired before the insert item is displayed/created. That is why then the InsertItem is null and the InsertItemPosition is None. You can use them in the listview PreRender event instead to achieve your goal. Or directly in the layout declaration as in the demo.

Best wishes,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ListView
Asked by
Pako
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Pako
Top achievements
Rank 1
Share this question
or