插入到gridview中的Ajax CalendarExtender将填充在同一行中

时间:2013-01-14 14:12:17

标签: c# asp.net gridview calendarextender

我遇到了CalendarExtender ajax的问题​​。 我在模板字段中有一个日历的gridview但是当我运行应用程序时,例如我有5个数据行,我的日历都在第一个。 有人可以解释一下为什么吗? 有我的代码:

 <asp:GridView ID="gvFeatureCustomer" runat="server" DataKeyNames="Id" AutoGenerateColumns="False"
            ClientIDRowSuffix="Id" OnRowDataBound="dtgdResult_RowDataBound" ClientIDMode="Static"
            ShowHeader="false" CssClass="datagrid" Style="width: 100%;" OnRowCommand="gvFeatureCustomer_RowCommand"
            OnRowDeleting="gvFeatureCustomer_RowDeleting">
            <Columns>
                <asp:TemplateField HeaderText="Nome" FooterText="Nome" SortExpression="Name">
                    <ItemTemplate>
                        <asp:DropDownList ID="ddlName" ClientIDMode="Predictable" runat="server" DataValueField="id"
                            DataTextField="Name" Style="width: 100%;">
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Valore" FooterText="Valore" SortExpression="Value">
                    <ItemTemplate>
                        <asp:TextBox ID="txtValue" AutoPostBack="true" runat="server" CssClass="auto-feature"
                            OnTextChanged="txtValue_TextChanged" Style="width: 100%"></asp:TextBox>
                        <ajaxToolkit:CalendarExtender ID="CalendarExtender99" ClientIDMode="AutoID" Format="dd/MM/yyyy" TargetControlID="txtValue" runat="server">
                        </ajaxToolkit:CalendarExtender>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:CommandField HeaderText="Delete" FooterText="Delete" Visible="true" HeaderStyle-Width="25"
                    ItemStyle-HorizontalAlign="Center" DeleteImageUrl="~/images/delete2.png" ButtonType="Image"
                    ShowDeleteButton="true" />

            </Columns>
        </asp:GridView>

谢谢!

2 个答案:

答案 0 :(得分:1)

你应该删除

ClientIDMode="Static"
来自GridView定义的

属性,因为如果您使用它,则所有TextBox控件都将具有相同的ID,“txtValue”。 CalendarExtender控件将找到第一个值(位于第一行)并将全部映射到它。

如果您想要优化控件ID分配的模式,here会更多地了解该主题。

答案 1 :(得分:0)

ClientIDMode="AutoID"添加到TextBox。 Asp.net将找出该做什么。

相关问题