jqueryasp.netdatalistedititemtemplate

Using jquery with EditItemTemplate of Datalist control


Is it possible to access controls inside EditItemTemplate of Datalist control using jquery. I have difficult time doing it, because "Edit" row is not rendered in html.

The only alternative I thanked of is not using DataList EditItemTemplate, but rather go only with jquery to hide and show rows and use ajax to update the contents of a row.

But, I would still want to hear option for EditItemTemplate and jquery.

Thanks


Solution

  • the html is rendered but only when you click on [Edit] see this post it shoud help you http://forums.asp.net/t/1668230.aspx/1

    try this: javascript:

    <script type="text/javascript">
        $(document).ready(function () {         
            showID();
        });
    
        function showID() {         
            if ($("[id*=QtyTextBox]").length)
                alert($("[id*=QtyTextBox]").attr("id"));
        }
    </script>
    

    EditItemTemplate:

    <EditItemTemplate>              
                Quantity:
                <asp:TextBox ID="QtyTextBox" Text='<%# DataBinder.Eval(Container.DataItem, "Qty") %>'
                    runat="server" />
                <br />              
                <asp:LinkButton ID="UpdateButton" Text="Update" CommandName="Update"
                    runat="server" />               
            </EditItemTemplate>