HTML Gridview的EditItemTemplate中的输入控件

HTML Input control in EditItemTemplate of a Gridview

我在 GridviewEditItemTemplate 中有一个 HTML 输入日期控件。 我面临的问题是,在编辑模式下,当控件是数据绑定时,日期选择器没有出现

 <asp:TemplateField HeaderText="Date Of Publication" SortExpression="DateOfPublication">
                    <EditItemTemplate>
                        <input id="tbDateOfPublicationEdit" runat="server" type="text" placeholder="Date Of Publication" title="Date Of Publication"
                            value='<%# Item.DateOfPublication == null ? "" : Item.DateOfPublication.Value.ToShortDateString() %>' />                                           
                    </EditItemTemplate>

整个Gridview都在这里

   <asp:GridView ID="gvAttachments" runat="server" AutoGenerateColumns="False" CellPadding="5" class="table" ItemType="Form_Attachment"
            DataKeyNames="Form_AttachmentID" ForeColor="Black" GridLines="Vertical" BorderColor="#007D40"
            OnRowDeleting="gvAttachments_RowDeleting"
            OnRowEditing="gvAttachments_RowEditing" OnRowCancelingEdit="gvAttachments_RowCancelingEdit"
            OnRowUpdating="gvAttachments_RowUpdating" OnRowDataBound="gvAttachments_RowDataBound"                
            AllowPaging="True" OnPageIndexChanging="gvAttachments_PageIndexChanging" PageSize="50" ShowFooter="True">
            <FooterStyle BackColor="#007D40"
                Font-Size="Larger" Font-Strikeout="False" />
            <RowStyle BackColor="#F7F6F3" ForeColor="Black" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="Black" />
            <PagerSettings Mode="NumericFirstLast" NextPageText="Page" />
            <PagerStyle BackColor="#1A1718" ForeColor="White" HorizontalAlign="Center"
                Font-Bold="True" Font-Italic="False" Font-Names="Copperplate Gothic Light"
                Font-Size="X-Large" />
            <HeaderStyle BackColor=" #007D40" Font-Bold="True" ForeColor="White" Width="100px" />
            <AlternatingRowStyle BackColor="White" ForeColor="#333333" />
            <EditRowStyle BackColor="#999999" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate> <asp:Label ID="lblSerialNo" runat="server" Text='<%# Container.DataItemIndex +1 %>'></asp:Label> </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ShowHeader="False" ControlStyle-Width="100px">
                    <EditItemTemplate>
                        <asp:LinkButton ID="lbtnUpdate" runat="server" CausesValidation="True" CommandName="Update" ToolTip="Update" CssClass="btn btn-default">
                      Update <span class="glyphicon glyphicon-ok" aria-hidden="true"></span> 

                        </asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="lbtnCancel" runat="server" CausesValidation="False" CommandName="Cancel" ToolTip="Cancel" CssClass="btn btn-default">
                          Cancel <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 
                        </asp:LinkButton>
                    </EditItemTemplate>
                    <ItemStyle Width="10px" />
                    <ItemTemplate>
                        <div id="divEditDelDownload" runat="server">
                            <asp:LinkButton ID="lbtnEdit" runat="server" CausesValidation="False" CommandName="Edit" ToolTip="Edit" CssClass="btn btn-default">
                     Edit <span class="glyphicon glyphicon-edit" aria-hidden="true"></span> 
                            </asp:LinkButton>
                            <br />
                            <asp:LinkButton ID="lbtnDelete" runat="server" CausesValidation="false" CommandName="Delete" ToolTip="Delete" CssClass="btn btn-default"
                                Visible='<%# (int.Parse(Eval("RoleID").ToString()) == Master.RoleID)|| Master.RoleID ==(int) RoleID.VRGSSR%>'
                                OnClientClick="return ShowConfirm(this.id);">
                    Delete <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                            </asp:LinkButton>

                            <br />
                            <asp:LinkButton ID="lbtnDownload" runat="server" CausesValidation="false"
                                Visible='<%# Item.DocumentName != "" %>' OnPreRender="lbtnDownload_PreRender"
                                CommandName="Select" ToolTip='<%# Item.DocumentName %>' CssClass="btn btn-default">
                   Open <span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span> 
                            </asp:LinkButton>
                        </div>
                    </ItemTemplate>
                    <FooterTemplate>
                        <asp:UpdatePanel ID="UpdatePanelFileUpload2" runat="server">
                            <Triggers>
                                <asp:PostBackTrigger ControlID="lbtnAdd" />
                            </Triggers>
                            <ContentTemplate>
                                <div style="width: 100px">
                                    <asp:LinkButton ID="lbtnAdd" runat="server" CausesValidation="False" CommandName="Add" ToolTip="Add" CssClass="btn btn-default" OnClick="lbtnAdd_Click">
                                        Add <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 
                                    </asp:LinkButton>
                                    <br />
                                    <input id="ApplicationAttachmentAddSingle" runat="server" type="file" title="Browse" accept=".pdf" />
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Form_AttachmentID" HeaderText="AttachmentID" Visible="False" />
                <asp:BoundField DataField="ApplicationID" HeaderText="ApplicationID" Visible="False" />
                <asp:TemplateField HeaderText="Type of Work">
                    <ItemTemplate>
                        <asp:Label ID="lblAttachmentCategory" runat="server" Text='<%#((AttachmentCategoryID)(int.Parse(Item.AttachmentCategoryID.ToString()))).ToString().Replace("_"," ") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddlAttCat" runat="server" SelectedValue='<%# Item.AttachmentCategoryID %>' DataTextField="Text" DataValueField="Value"
                            DataSource='<%# Enum.GetNames(typeof(AttachmentCategoryID)).Select(s => new { Text = s.Replace("_", " "),Value = (int)(Enum.Parse(typeof(AttachmentCategoryID),s)) })%>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:DropDownList ID="ddlAttCatAdd" runat="server" DataTextField="Text" DataValueField="Value"
                            DataSource='<%# Enum.GetNames(typeof(AttachmentCategoryID)).Select(s => new { Text = s.Replace("_", " "),Value = (int)(Enum.Parse(typeof(AttachmentCategoryID),s)) })%>'>
                        </asp:DropDownList>
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Title" SortExpression="Description">
                    <EditItemTemplate>
                        <asp:TextBox ID="tbDescriptionEdit" TextMode="MultiLine" runat="server" Text='<%# Item.Description %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblDescription" runat="server" Text='<%# Item.Description %>'></asp:Label>
                    </ItemTemplate>
                    <FooterTemplate>
                        <textarea  id="tbDescriptionAdd" runat="server" textmode="MultiLine" placeholder="Title" title="Title"></textarea>
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Date Of Publication" SortExpression="DateOfPublication">
                    <EditItemTemplate>


                        <input id="tbDateOfPublicationEdit" runat="server" type="text" placeholder="Date Of Publication" title="Date Of Publication"
                            value='<%# Item.DateOfPublication == null ? "" : Item.DateOfPublication.Value.ToShortDateString() %>' />

                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblDateOfPublication" runat="server" Text='<%# Item.DateOfPublication == null ? "" : Item.DateOfPublication.Value.ToShortDateString() %>'></asp:Label>
                    </ItemTemplate>
                    <FooterTemplate>

                        <input id="tbDateOfPublicationAdd" runat="server" type="date" placeholder="Date Of Publication" title="Date Of Publication" />
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Journal" SortExpression="Journal">
                    <EditItemTemplate>
                        <asp:TextBox ID="tbJournalEdit" TextMode="MultiLine" runat="server" Text='<%# Item.Journal %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblJournal" runat="server" Text='<%# Item.Journal %>'></asp:Label>
                    </ItemTemplate>
                    <FooterTemplate>
                        <textarea id="tbJournalAdd" runat="server" textmode="MultiLine" placeholder="Journal " title="Journal "></textarea>
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Uploaded By" Visible="false">
                    <ItemTemplate>
                        <asp:Label ID="lblEmployeeName" runat="server" Text='<%# GetEmployeeName()%>'> </asp:Label>
                        <br />
                        <asp:Label ID="lblRole" runat="server" CssClass="label label-default" Text='<%#((RoleID)(int.Parse(Item.RoleID.ToString()))).ToString().Replace("_"," ") %>'></asp:Label>

                    </ItemTemplate>
                </asp:TemplateField>
                 <asp:TemplateField HeaderText="Selection For Ext. Reviewers">
                     <ItemStyle HorizontalAlign="Center" />
                    <ItemTemplate>
                        <asp:CheckBox ID="cbSel4ExtRev" runat="server"
                            Checked='<%#  Item.SelectionForExtRev%>'
                            AutoPostBack="True"
                            OnCheckedChanged="cbSel4ExtRev_CheckedChanged"
                            ToolTip="Check to enable this document to be viewed by External Reviewers" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="No Of Authors">
                    <ItemTemplate>


                        <asp:TextBox runat="server" MaxLength="50" AutoPostBack="true" Text='<%# Item.NoOfAuthors%>' TextMode="Number" ID="tbNoOfAuthors" OnTextChanged="tbNoOfAuthors_TextChanged" Width="50px"></asp:TextBox>

                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Is First Author?">
                    <ItemStyle HorizontalAlign="Center" />
                    <ItemTemplate>
                        <asp:CheckBox ID="cbFirstAuthor" runat="server"
                            Checked='<%#  Item.FirstAuthor%>'
                            AutoPostBack="True"
                            OnCheckedChanged="cbFirstAuthor_CheckedChanged"
                            ToolTip="Check if the applicant is the First Author" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Points">
                    <ItemTemplate>
                        <asp:Label ID="lblPoints" runat="server" Text='<%# Item.Points %>'></asp:Label>
                    </ItemTemplate>
                    <FooterTemplate>
                        Total:
                        <asp:Label ID="lblPoints" runat="server" Text='<%# GetTotalPoints() %>'></asp:Label>
                    </FooterTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Acceptable?">
                    <ItemTemplate>
                        <asp:CheckBox ID="cbAccept" runat="server"
                            Checked='<%#  Item.Accept%>'
                            AutoPostBack="True"
                            OnCheckedChanged="cbAcceptable_CheckedChanged"
                            ToolTip="Check if the publication is acceptable" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Remarks" SortExpression="Remarks">
                    <EditItemTemplate>
                        <asp:TextBox ID="tbRemarksEdit" TextMode="MultiLine" runat="server" Text='<%# Item.Remarks %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblRemarks" runat="server" Text='<%# Item.Remarks %>'></asp:Label>
                    </ItemTemplate>
                    <FooterTemplate>
                        <textarea id="tbRemarksAdd" runat="server" textmode="MultiLine" placeholder="Remarks" title="Remarks"></textarea>
                    </FooterTemplate>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                [<em>No files were uploaded for this application</em>]
            </EmptyDataTemplate>
        </asp:GridView>

尝试改变

<input id="tbDateOfPublicationEdit" runat="server" type="text" placeholder="Date Of Publication" title="Date Of Publication"

 <input id="tbDateOfPublicationEdit" runat="server" type="date" placeholder="Date Of Publication" title="Date Of Publication"

我认为日期选择器使用 JavaScript 所以如果你使用 runat="server",日期选择器将不会显示。