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

Bind value to CommmandItem Link Detailtable

1 Answer 9 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 04 Nov 2014, 10:18 PM
Trying to bind a value to a radbutton that sits in my detailtable commantiemtemplate.  Code works but no values are ever put through, checekd to make sure there is data and the database returns a value but when I click on button and alert nothing comes through the event_args.  If I put on the main grid table it all works just fine but not on detail table.

<DetailTables>
                                       <telerik:GridTableView AutoGenerateColumns="false" Font-Size="9" Name="LeaseDates" BorderWidth="2px" DataKeyNames="intLeaseDateId" Width="30%" CommandItemDisplay="Top" >
                                           <ItemStyle HorizontalAlign="Center" BorderWidth="2px" /><AlternatingItemStyle BackColor="#B0C4DE"  HorizontalAlign="Center" /><HeaderStyle HorizontalAlign="Center" />
                                               <CommandItemStyle Height="25px" HorizontalAlign="Left" Font-Underline="true"  />
                                               <CommandItemTemplate>
                                                   <telerik:RadButton ID="btnDates" runat="server" ButtonType="SkinnedButton" Text="Manage Dates" AutoPostBack="false" OnClientClicked="LoadDates" CommandArgument='<%# Bind("intLeaseID")%>'></telerik:RadButton>
                                               </CommandItemTemplate>
                                               <Columns>
                                                   <telerik:GridBoundColumn HeaderText="Start Date" DataField="dtStartDate" UniqueName="Start" />
                                                   <telerik:GridBoundColumn HeaderText="End Date" DataField="dtEndDate" UniqueName="End" />
                                               </Columns>
 
 
 Protected Sub myradGrid_DetailTableDataBind(sender As Object, e As GridDetailTableDataBindEventArgs) Handles myradGrid.DetailTableDataBind
 
       sql = "Select intleaseDateId, intLeaseID, dtstartDate, dtEndDate from vw_LeaseDates where intLeaseID  = " & e.DetailTableView.ParentItem.GetDataKeyValue("intLeaseID") & ""
 
       e.DetailTableView.DataSource = getReader(sql)
   End Sub
 
 function LoadDates(sender, eventargs) {
               var radLease = $find("<%= radLease.ClientID%>");
               var LeaseId = sender.get_commandArgument();
               alert(LeaseId);
               radLease.setUrl("../TaccAdmin/Dates.aspx?Lease=" + LeaseId);
               radLease.set_width("700");
               radLease.set_height("400");
               radLease.show();
           }








1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 07 Nov 2014, 10:02 AM
Hi Kevin,

Although you can modify your logic for retrieving the "intLeaseID" from the parent GridDataItem, this will cause issues when you expand an item, since the parent item will not be data-bound in the current page's lifecycle and the value will not be retrieved.

The correct way for handling this would be the following:
<CommandItemTemplate>
    <telerik:RadButton ID="btnDates" runat="server" ButtonType="SkinnedButton" Text="Manage Dates" AutoPostBack="false" OnClientClicked="LoadDates"
        CommandArgument='<%# Container.OwnerTableView.ParentItem.GetDataKeyValue("intLeaseID").ToString() %>'></telerik:RadButton>

Hope this helps.


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or