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

Using RadToolBar, RadListView ItemCommand

7 Answers 185 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Caglar Duman
Top achievements
Rank 1
Caglar Duman asked on 18 Jul 2010, 01:02 PM
Hi,

I've a RadToolBar in RadListView's itemTemplate.
My problem is that; When I give CommandName to RadToolBarButtons. listview's ItemCommand function doesn't catch it.

protected void lv_ItemCommand(object source, RadListViewCommandEventArgs e)
{
...
}

..
<
telerik:RadToolBar ID="tb" runat="server">
<Items>
<telerik:RadToolBarButton runat="server"  text="test" CommandName="Edit"></telerik:RadToolBarButton>
</Items>
</telerik:RadToolBar>
..


only if I give a buttonClick command to RadToolBar, tb_ButtonClick function can do it..
<telerik:RadToolBar ID="tb" runat="server" OnButtonClick="tb_ButtonClick">
<Items>
<telerik:RadToolBarButton runat="server"  text="test" CommandName="Edit"></telerik:RadToolBarButton>
</Items>
</telerik:RadToolBar>


My Question is that; Is there any way to catch ListView_ItemCommand function by not using RadToolBar ButtonClick ?


Thanks
Sincerely,
Caglar DUMAN

7 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 22 Jul 2010, 02:44 PM
Hello Caglar,

I'm not sure I understand the this requirement. Could you please explain in more details and send us more sample code? Thanks in advance

Best wishes,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Caglar Duman
Top achievements
Rank 1
answered on 23 Jul 2010, 07:04 AM

Hello Yana,

My question is that Listview's ItemCommand handler doesn't catch RadToolBarButton Clicks? Why?
0
Yana
Telerik team
answered on 28 Jul 2010, 03:05 PM
Hi Caglar,

You should set AutoPostBack property of the toolbar to true and ItemCommand event will be fired as expected:

<telerik:RadToolBar ID="RadToolBar1"  runat="server" AutoPostBack="true">

All the best,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Caglar Duman
Top achievements
Rank 1
answered on 29 Jul 2010, 07:26 AM

Thank you Yana it has worked :)

By the way, 
Can I fire InitInsert command of itemCommand event from outside the listview ?

this code doesn't fire initinsert command:

<telerik:RadListView>
...
...
</telerik:RadListView>          
  
<telerik:RadToolBar ID="tbInitInsert" runat="server" AutoPostBack="true">
  <Items>
   <telerik:RadToolBarButton Text="Insert" CommandName="InitInsert">
   </telerik:RadToolBarButton>
  </Items>
</telerik:RadToolBar>

Thank you

Sincerely,
Çağlar DUMAN
0
Yana
Telerik team
answered on 02 Aug 2010, 02:33 PM
Hello Caglar,

I'm afraid that this cannot be done outside the listview.

Best regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
L. M. Pathan
Top achievements
Rank 1
answered on 26 Nov 2011, 04:37 PM
Telerik Team,

I am using RadToolBar for Command Item inside a RadGrid but RadToolBarButton doesn't fire InitInsert Command.

<CommandItemTemplate>
            <telerik:RadToolBar OnClientButtonClicked="onRadToolBarButtonClicked" Skin="Vista"
                ID="RadToolBar1" runat="server" AutoPostBack="true">
                <Items>
                    <telerik:RadToolBarButton Text="Add new student" ID="btnInitInsert" runat="server"
                        CommandName="InitInsert" ImageUrl="~/images/telerik/AddRecord.gif" ImagePosition="Left">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton Text="Delete student" ID="btnDelete" runat="server" CommandName="Delete"
                        ImageUrl="~/images/telerik/Delete.gif" ImagePosition="Left">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton Text="Toggle filtering" ID="ToggleFiltering" runat="server"
                        CommandName="ToggleFilterBar" ImageUrl="~/images/telerik/search.png" ImagePosition="Left">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton Text="Refresh" ID="btnRefresh" runat="server" CommandName="RebindGrid"
                        ImageUrl="~/images/telerik/Refresh.gif" ImagePosition="Left" CausesValidation="false">
                    </telerik:RadToolBarButton>
                </Items>
            </telerik:RadToolBar>
        </CommandItemTemplate>

How do I manage this? Please advise. Thank you for your help.

Regards

Pathan L.
0
Shinu
Top achievements
Rank 2
answered on 28 Nov 2011, 06:47 AM
Hello Pathan,

I have tried the same in the version 2011.2.712.35 which worked as expected. Make sure that the CommandName is fired in ItemCommand event.
C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
  if (e.CommandName == "InitInsert")
   {//your code
   }
}

-Shinu.
Tags
ToolBar
Asked by
Caglar Duman
Top achievements
Rank 1
Answers by
Yana
Telerik team
Caglar Duman
Top achievements
Rank 1
L. M. Pathan
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or