2013-01-14 28 views
-1

我對CalendarExtender ajax有問題。 我有一個gridview的日曆在templatefield,但是當我運行的應用程序,例如我有5個數據行,我的日曆都在第一輪。 有人可以解釋我爲什麼? 有我的代碼:在GridView中插入的Ajax CalendarExtender填充在同一行中

<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> 

謝謝!

+0

你爲什麼不接受解決方案? – Sampath

回答

1

您應該從GridView定義中移除

ClientIDMode="Static" 

屬性,因爲如果你使用它,你的所有TextBox控件將具有相同的ID,「txtValue」。 CalendarExtender控件將找到第一個值(位於第一行),並將全部映射到它。

如果您想改進控件ID分配的模式,here的主題更多。

0

ClientIDMode="AutoID"添加到TextBox。 Asp.net會找出該怎麼做。