gridview中的日期选择器未弹出-vs2010 [英] date picker in gridview not popping - vs2010

查看:85
本文介绍了gridview中的日期选择器未弹出-vs2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:GridView runat="server" ID="MyGridView" AutoGenerateColumns="false">
        <Columns>
           <asp:BoundField DataField="Col1" HeaderText="Column 1" />
           <asp:BoundField DataField="Col2" HeaderText="Date 1" />
           <asp:BoundField DataField="Col3" HeaderText="Date 2" />
           <asp:TemplateField HeaderText="Date 2" >
                <EditItemTemplate>
                    <asp:TextBox ID="txtDate" CssClass="datepickerCompleted"
                        runat="server" Text="2011/1/1" ></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>        
           <asp:BoundField DataField="Col4" HeaderText="Date 3" />
           <asp:TemplateField HeaderText="Date 3"></asp:TemplateField>
        </Columns>
    </asp:GridView>
   <script type="text/javascript" language="javascript" src="<%= VirtualPathUtility.ToAbsolute("~/Script/jquery-1.4.1-vsdoc.js")%>"></script>
<script type="text/javascript">

    $(function () {
        $(".datepickerCompleted").datepicker();
    });
</script>
</asp:Content>

以下是此处的示例:在此处输入链接描述

当我查看源代码时,我没有在txtDate文本框中看到任何填充的值,因此我怀疑这没有触发jquery方法.

When I look at the source, i do not see any value populate in txtDate text box, which i suspect is then not firing the jquery method..

我该如何调试?

推荐答案

您的代码看起来不错,但是 datepicker 是jQuery UI的一部分,jQuery UI是单独的下载/脚本-不包含在其中jquery-1.4.1文件,看起来这是您引用的唯一脚本.

Your code looks good, but the datepicker is part of jQuery UI which is a separate download/script--it's not included in the jquery-1.4.1 file, and it looks like that's the only script you have referenced.

编辑:这是一个对我有用的示例:

EDIT: Here's an example that works for me:

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">

    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {
            $(".datepickerCompleted").datepicker();
        });
    </script>
</asp:Content>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <asp:GridView runat="server" ID="MyGridView" AutoGenerateColumns="false">
        <Columns>
           <asp:TemplateField HeaderText="Date 2">                
                <ItemTemplate>
                    <asp:TextBox ID="txtDate" CssClass="datepickerCompleted" runat="server" Text="2011/1/1" ></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>        
        </Columns>
    </asp:GridView>

</asp:Content>

您可以在此处

You can download a copy of jQuery UI here, and here's some more information on the datapicker.

这篇关于gridview中的日期选择器未弹出-vs2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆