[RESOLVED]click on edit, show cancel link on this specified row only

I am clicking on edit link of a row . i Want to hide a column of Edit link & need to show the cancel link. how could i do that ?

Hi,

Not fully understood your requirement,but try out this prototype and see if this satisfies your requirement.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>
        $(document).ready(function () {
            $('.cancel').hide();
            $('.edit').click(function () {
                $(this).hide();
                $(this).next().show();
            });
        });
    </script>
    <table>
        <tr>
            <td>
                <a href="#" class="edit">Edit</a>
                <a href="#" class="cancel">Cancel</a>
            </td>
            <td></td>
        </tr>
        <tr>
            <td>
                <a href="#" class="edit">Edit</a>
                <a href="#" class="cancel">Cancel</a>
            </td>
            <td></td>
        </tr>
        <tr>
            <td>
                <a href="#" class="edit">Edit</a>
                <a href="#" class="cancel">Cancel</a>
            </td>
            <td></td>
        </tr>
    </table>

Hi waqar1,
From your description, if you are using Gridview, you could put the Edit button into the ItemTemplate, and put the Cancel button into the EditItemTemplate. You could refer to the following code:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowEditing="OnRowEditing">
<Columns>
    <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
    <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
    <asp:TemplateField>
        <ItemTemplate>
            <asp:LinkButton Text="Edit" runat="server" CommandName="Edit" />
        </ItemTemplate>
        <EditItemTemplate>
            <asp:LinkButton Text="Update" runat="server" OnClick="OnUpdate" />
            <asp:LinkButton Text="Cancel" runat="server" OnClick="OnCancel" />
        </EditItemTemplate>
    </asp:TemplateField>
</Columns>
</asp:GridView>

More details, please refer to the following links:

http://www.aspsnippets.com/Articles/Edit-GridView-using-BoundField-Column-in-ASPNet.aspx

http://www.aspsnippets.com/Articles/Insert-Update-Edit-Delete-record-in-GridView-using-SqlDataSource-in-ASPNet.aspx

if you are use a table as sangeeth2007 said, you could use the following code:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.cancel').hide();
            $('.edit').click(function () {
                $(this).hide();
                $(this).next().show();
            });
            $('.cancel').click(function () {
                $(this).hide();
                $('.edit').show();
            });
        });
    </script>

  <table>
        <tr>
            <td>
                <a href="#" class="edit">Edit</a>
                <a href="#" class="cancel">Cancel</a>
            </td>
            <td></td>
        </tr>
        <tr>
            <td>
                <a href="#" class="edit">Edit</a>
                <a href="#" class="cancel">Cancel</a>
            </td>
            <td></td>
        </tr>
        <tr>
            <td>
                <a href="#" class="edit">Edit</a>
                <a href="#" class="cancel">Cancel</a>
            </td>
            <td></td>
        </tr>
    </table>

If you have any other questions about my reply, please let me know freely.
Best Regards,
Dillion

Leave a Reply