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

CommandItemTemplate Question - Detail Tables

3 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reid
Top achievements
Rank 2
Reid asked on 15 Mar 2009, 04:00 AM
How can I access the Edit State of a Detail Table?  The code below can set the state of the CommandItemTemplate's LinkButton based on the EditIndexes.Count like below:

<td style="width: 80px">  
  <asp:LinkButton ID="btnUpdateCommandSponsor" runat="server" CommandArgument="Update" 
     CommandName="Update" ToolTip="Update Sponsor Record" Visible="<%# grdSponsoredLinkSponsor.EditIndexes.Count > 0 %>"><img alt=""   
       src="images/icons/edit.png" style="border: 0px" /> Update</asp:LinkButton> 
</td> 

How can you get the EditIndexes count or state of the embedded or nested Detail Table?

3 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 16 Mar 2009, 02:39 PM
Hello Reid,

Please examine the following snippet:
 <CommandItemTemplate> 
     <asp:Button ID="Button1" runat="server" Text="Button1" OnPreRender="Button1_PreRender" /> 
 </CommandItemTemplate> 
 

protected void Button1_PreRender(object sender, EventArgs e) 
    bool enabled = true
    foreach (GridDataItem item in ((GridCommandItem)((Control)sender).NamingContainer).OwnerTableView.Items) 
    { 
        if (item.Edit) 
        { 
            enabled = false
            break
        } 
    } 
    ((Button)sender).Enabled = enabled; 

Best regards,
Daniel
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Reid
Top achievements
Rank 2
answered on 16 Mar 2009, 02:53 PM
Thank you for the code.  I think that it would be handled a bit cleaner if the GridTableView objects had their own edit index count property.  And we could use something like :

<td style="width: 80px">     
  <asp:LinkButton ID="btnUpdateCommandSponsor" runat="server" CommandArgument="Update"    
     CommandName="Update" ToolTip="Update Sponsor Record" Visible="<%# grdSponsoredLinkSponsor.MasterTableView.DetailsTables[0].EditIndexes.Count > 0 %>"><img alt=""      
       src="images/icons/edit.png" style="border: 0px" /> Update</asp:LinkButton>    
</td>  

or

<td style="width: 80px">     
  <asp:LinkButton ID="btnUpdateCommandSponsor" runat="server" CommandArgument="Update"    
     CommandName="Update" ToolTip="Update Sponsor Record" Visible="<%# grdSponsoredLinkSponsor.getDetailTableEditIndexCount("MyGridViewName") > 0 %>"><img alt=""      
       src="images/icons/edit.png" style="border: 0px" /> Update</asp:LinkButton>    
</td>   
 


Thanks
0
Daniel
Telerik team
answered on 17 Mar 2009, 03:20 PM
Hello Reid,

Thank you for your suggestion. I passed it to our developers for future consideration.

Regards,
Daniel
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Reid
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Reid
Top achievements
Rank 2
Share this question
or