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

CommandItemTemplate Rebind

2 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeroen Eikmans
Top achievements
Rank 1
Jeroen Eikmans asked on 04 Nov 2010, 04:58 PM
Hello,

I have a RadGrid with one detailtable.
Both the MasterTableView as the DetailTable GridTableView have the following CommandItemTemplate
<CommandItemTemplate>
  <div style="padding: 5px 5px 5px 5px; float: right; display: inline">
    <asp:LinkButton ID="RebindButton" runat="server" CommandName="RebindGrid" ToolTip="Refresh">
      <asp:Image ID="RebindImage" runat="server" ImageUrl="~/Images/Refresh.gif" ImageAlign="Middle" />
    </asp:LinkButton>
  </div>                                            
</CommandItemTemplate>

When i click the refresh button on the DetailTable, the MasterTableView gets rebound.
Is it possible to only have the DetailTable GridTableView to rebind?

Kind regards.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 05 Nov 2010, 06:48 AM
Hello Roel,

One option is you can set different CommandName for the Rebind button in MasterTable and DetailTable. And rebind the given detail table view through the following line of code in the ItemCommand event:

ASPX:
<MasterTableView Name="Master" runat="server" DataKeyNames="EmployeeID" CommandItemDisplay="Top">
   <CommandItemTemplate>
       <div style="padding: 5px 5px 5px 5px; float: right; display: inline">
          <asp:LinkButton ID="RebindButton" runat="server" CommandName="RebindGrid" ToolTip="Refresh">
                <asp:Image ID="RebindImage" runat="server" ImageUrl="~/Images/Refresh.gif" ImageAlign="Middle" />
           </asp:LinkButton>
       </div>
  </CommandItemTemplate>
      <DetailTables>
         <telerik:GridTableView Name="GridTableView1" runat="server" CommandItemDisplay="Top">
           <CommandItemTemplate>
               <div style="padding: 5px 5px 5px 5px; float: right; display: inline">
                   <asp:LinkButton ID="RebindButton" runat="server" CommandName="RebindDetail" ToolTip="Refresh">
                       <asp:Image ID="RebindImage" runat="server" ImageUrl="~/Images/Refresh.gif" ImageAlign="Middle" />
                   </asp:LinkButton>
                </div>
         </CommandItemTemplate>
 . . . . . . . . . . . . . . .

C#:
protected void RadGrid2_ItemCommand(object source, GridCommandEventArgs e)
   {
       if (e.CommandName == "RebindDetail") // when clicking Rebind button in DetailTable
       {      
           e.Item.OwnerTableView.Rebind();
       }
   }

Another option (when setting same CommandName) is  canceling the event(cancel rebinding the grid) when clicking the Rebind button  and then manually rebind the DetailTable.
C#:
protected void RadGrid2_ItemCommand(object source, GridCommandEventArgs e)
  {
      if (e.CommandName == "RebindGrid" && e.Item.OwnerTableView.Name == "GridTableView1")
      {
          e.Canceled = true;
          e.Item.OwnerTableView.Rebind();
      }
  }


Thanks,
Princy.
0
Jeroen Eikmans
Top achievements
Rank 1
answered on 05 Nov 2010, 08:45 AM
Hi Princy,

Works perfect!
Thanks for your help.

Kind regards.
Tags
Grid
Asked by
Jeroen Eikmans
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeroen Eikmans
Top achievements
Rank 1
Share this question
or