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

[Solved] Not Showing CommandItemTemplate Links

1 Answer 183 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 10 Sep 2009, 05:05 AM

I have a grid that when I go into edit mode I loose my Links except for refrest.

Here is part of my code.

 

 <table>
        <asp:Repeater ID="Repeater1" runat="server">
       
            <ItemTemplate>
                    <tr class="comment">
                        <td align="left" colspan="2">
                            &lt;
                            <asp:Label ID="lblCreatedBy" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, "User.UserName") %>' />
                            &nbsp;
                            <asp:Label ID="lblCreatedDate" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, "CreatedDateTime") %>' />
                            &gt;
                        </td>
                        <td align="left">
                            <asp:Label ID="lblComment" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, "ApplicantNote") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td colspan="2">
                            <table>
                                <asp:Repeater ID="Repeater2" runat="server" DataSource='<%# DataBinder.Eval(Container.DataItem, "Notes") %>'>
                                    <ItemTemplate>
                                        <tr class="comment">
                                            <td align="left">
                                                <
                                                <asp:Label ID="lblCreatedBy2" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, "User.UserName") %>' />
                                                &nbsp;
                                                <asp:Label ID="lblCreatedDate2" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, "CreatedDateTime") %>' />
                                                >
                                            </td>
                                            <td align="left">
                                                <asp:Label ID="lblComment2" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, ApplicantNote") %>' />
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </table>
                        </td>
                    </tr>
            </ItemTemplate>
        </asp:Repeater>
    </table>

    <table style="margin-left:auto; margin-right:auto; border-style: solid; border-color: Navy; border-width: 2px;" width="760px">
        <tr>
            <td style="margin-left:auto; margin-right:auto">
                <asp:Label ID="noteTitleLabel"
                               runat="server"
                               Text="Note for "
                               Font-Bold="true" />
                <asp:Label ID="noteApplicant"
                               runat="server"
                               Font-Bold="true" />
            </td>
        </tr>
        <tr>
            <td>
                <telerik:RadGrid ID="gridComments"
                                runat="server"
                                Skin="Vista" Width="750px"
                                OnDetailTableDataBind="gridComments_DetailDataBind" OnNeedDataSource="gridComments_NeedDataSource"
                                OnInsertCommand="gridComments_InsertCommand"
                    ondeletecommand="gridComments_Delete" onupdatecommand="gridComment_Update"
                    onitemdatabound="gridComment_ItemDataBound" >
                    <MasterTableView AutoGenerateColumns="false"
                                    DataKeyNames="NoteID, ParentID"
                                    CommandItemDisplay="Top" EditMode="PopUp">
                        <DetailTables>
                            <telerik:GridTableView AutoGenerateColumns="false"
                                                    CommandItemDisplay="Top" DataKeyNames="NoteID, ParentID"  Width="710px">
                                <NoRecordsTemplate>
                                    <p>No replies to this comment</p>
                                </NoRecordsTemplate>
                                <Columns>
                                    <telerik:GridBoundColumn DataField="ParentID" Visible="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="User.UserName" UniqueName="User.UserNameChild" HeaderText="User">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="CreatedDateTime" HeaderText="Date" UniqueName="CreatedDateTimeChild">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="ApplicantNote" HeaderText="Note" UniqueName="ApplicantNoteChild">
                                    </telerik:GridBoundColumn>
                                </Columns>
                                <CommandItemTemplate>                                                         
                            <div style="padding:3px 0px;text-align:right;">
                               
                                    <asp:LinkButton ID="lnkEdit" runat="server" CommandName="EditSelected"
                                     CausesValidation="false" Visible='<%# (!gridComments.MasterTableView.IsItemInserted)&&(gridComments.EditIndexes.Count==0) %>'>
                                     <img style="border:0px;vertical-align:middle;"
                                     alt="" src="CssClass/Images/Edit.gif" />
                                     Edit / View
                             </asp:LinkButton>
                             &nbsp;
                                <asp:LinkButton Style="vertical-align: bottom" ID="lnkAdd" runat="server" CommandName="InitInsert"
                                        Visible='<%# !gridComments.MasterTableView.IsItemInserted && gridComments.EditIndexes.Count == 0 %>'>
                                    <img style="border:0px;"
                                        alt="" src="CssClass/Images/AddRecord.gif" />
                                    Leave Reply
                                </asp:LinkButton>
                                &nbsp;
                                 <asp:LinkButton ID="lnkDelete"
                                     OnClientClick="javascript:return confirm('Delete selected Note?')"
                                     runat="server"                                    
                                     CommandName="DeleteSelected"
                                     CausesValidation="false"
                                     Visible='<%# (!gridComments.MasterTableView.IsItemInserted)&&(gridComments.EditIndexes.Count==0) %>'>
                                     <img style="border:0px;vertical-align:middle;"
                                     alt="" src="CssClass/Images/Delete.gif" />
                                     Delete
                                     </asp:LinkButton>
                                &nbsp;
                               
                                <asp:LinkButton ID="lnkRefresh1" runat="server" CommandName="RebindGrid">
                                    <img style="border:0px;vertical-align:middle;"
                                        alt="" src="CssClass/Images/Refresh.gif" />
                                    Refresh
                                </asp:LinkButton>
                        </CommandItemTemplate>
                        <EditFormSettings EditFormType="Template">
                            <FormTemplate>
                                <table>
                                    <tr>
                                        <td align="center">
                                            Note
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:TextBox ID="noteTextBoxChild"
                                                 Width="375px"
                                                 ReadOnly="false"
                                                 onChange="Count(this,700)"
                                                 onKeyUp="Count(this,700)"
                                                 Height="195px"
                                                 runat="server"
                                                 
                                                 TextMode="MultiLine"
                                                 MaxLength="700" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center">
                                            <asp:Button ID="btnUpdate"
                                                Text='<%# (Container is GridEditFormInsertItem) ? "Save" : "Update" %>'
                                                runat="server"
                                                CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                            </asp:Button>
                                            &nbsp;
                                            <asp:Button ID="btnCancel" Text="Cancel"
                                                runat="server" CausesValidation="False"
                                                CommandName="Cancel">
                                            </asp:Button>
                                        </td>
                                    </tr>
                                </table>
                            </FormTemplate>
                        </EditFormSettings>
                       
                            </telerik:GridTableView>
                           
                        </DetailTables>
                       
                        <Columns>
                            <telerik:GridBoundColumn DataField="NoteID" Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="User.UserName" UniqueName="User.UserName" HeaderText="User">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="CreatedDateTime" HeaderText="Date" UniqueName="CreatedDateTime">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ApplicantNote" HeaderText="Note" UniqueName="ApplicantNote">
                            </telerik:GridBoundColumn>
                        </Columns>
                        <CommandItemTemplate>
                            <div style="padding:3px 0px;text-align:right;">
                             <asp:LinkButton ID="lnkEdit" runat="server" CommandName="EditSelected"
                                     CausesValidation="false" Visible='<%# (!gridComments.MasterTableView.IsItemInserted)&&(gridComments.EditIndexes.Count==0) %>'>
                                     <img style="border:0px;vertical-align:middle;"
                                     alt="" src="CssClass/Images/Edit.gif" />
                                     Edit / View
                             </asp:LinkButton>

                            &nbsp;
                                <asp:LinkButton Style="vertical-align: bottom" ID="lnkAdd" runat="server" CommandName="InitInsert"
                                        Visible='<%# !gridComments.MasterTableView.IsItemInserted && gridComments.EditIndexes.Count == 0 %>'>
                                    <img style="border:0px;"
                                        alt="" src="CssClass/Images/AddRecord.gif" />
                                    Add Note
                                </asp:LinkButton>
                                &nbsp;
                                 <asp:LinkButton ID="lnkDelete"
                                     OnClientClick="javascript:return confirm('Delete selected Note?')"
                                     runat="server"                                    
                                     CommandName="DeleteSelected"
                                     CausesValidation="false"
                                     Visible='<%# (!gridComments.MasterTableView.IsItemInserted)&&(gridComments.EditIndexes.Count==0) %>'>
                                     <img style="border:0px;vertical-align:middle;"
                                     alt="" src="CssClass/Images/Delete.gif" />
                                     Delete
                                     </asp:LinkButton>
                                     &nbsp;
                                <asp:LinkButton ID="lnkRefresh1" runat="server" CommandName="RebindGrid">
                                    <img style="border:0px;vertical-align:middle;"
                                        alt="" src="CssClass/Images/Refresh.gif" />
                                    Refresh
                                </asp:LinkButton>
                        </CommandItemTemplate>
                        <EditFormSettings EditFormType="Template">
                            <FormTemplate>
                                <table>
                                    <tr>
                                        <td align="center">
                                            Note
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:TextBox ID="noteTextBox"
                                                 Width="375px"
                                                 ReadOnly="false"
                                                 onChange="Count(this,700)"
                                                 onKeyUp="Count(this,700)"
                                                 Height="195px"
                                                 runat="server"
                                            
                                                 TextMode="MultiLine"
                                                 MaxLength="700" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center">
                                            <asp:Button ID="btnUpdate"
                                                Text='<%# (Container is GridEditFormInsertItem) ? "Save" : "Update" %>'
                                                runat="server"
                                                CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                            </asp:Button>
                                            &nbsp;
                                            <asp:Button ID="btnCancel" Text="Cancel"
                                                runat="server" CausesValidation="False"
                                                CommandName="Cancel">
                                            </asp:Button>
                                        </td>
                                    </tr>
                                </table>
                            </FormTemplate>
                        </EditFormSettings>
                       
                        <NoRecordsTemplate>
                            <p>No comments have been added</p>
                        </NoRecordsTemplate>
                    </MasterTableView>
                    <ClientSettings >
                    <Selecting AllowRowSelect ="true" />
                   
                    </ClientSettings>
                </telerik:RadGrid>
            </td>
        </tr>
    </table>

Everything worked great until I added the Edit/View link and when the Edit/View link is clicked I only show Refresh icon.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Sep 2009, 05:35 AM
Hi Ryan,

In the above given aspx code i can see that you have set the Visibility of the Edit/Add/Delete button as
Visible='<%# (!gridComments.MasterTableView.IsItemInserted)&&(gridComments.EditIndexes.Count==0) %>' which would  obviously hide the linkbuttons when the Grid is in edit/insert mode. Try removing the Visible property of the LinkButtons and see whether it is working as expected.

Princy.
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or