2017-02-22 34 views
0

我有一個包含兩個DropDownLists的GridView。對於DataRecord,DropDownLists完全填充/綁定,但對於頁腳,它們保持爲空/未綁定。在DataRecord和Footer中,DropDownLists都有相同的SqlDataSource。可能是因爲頁腳中的DropDownLists沒有被填充/綁定?頁腳中的DropDownList沒有被填充/綁定

   <asp:GridView 
        ID="ExecutionGridView" 
        runat="server" 
        AutoGenerateColumns="False" 
        DataKeyNames="ID" 
        Font-Names="Calibri" 
        Font-Size="Small" 
        OnRowCommand="ExecutionGridView_RowCommand" 
        OnRowDataBound="ExecutionGridView_RowDataBound" 
        OnRowDeleting="ExecutionGridView_RowDeleting" 
        OnRowUpdating="ExecutionGridView_RowUpdating" 
        HorizontalAlign="Left"   
        ShowFooter="true"    
        Visible="False"> 
        <FooterStyle Font-Names="Calibri" Font-Size="Small" /> 
        <HeaderStyle Font-Names="Calibri" Font-Size="Small" HorizontalAlign="Left" CssClass="headerClass" ForeColor="#408080" BackColor="White" BorderColor="#408080" /> 
        <Columns>        
         <asp:TemplateField HeaderText="ID" ItemStyle-Width="30"> 
          <ItemTemplate> 
           <%# Eval("ID") %> 
           <input type="hidden" name="ExecutionId" value='<%# Eval("ID") %>' /> 
          </ItemTemplate> 
          <ItemStyle Width="30px" /> 
         </asp:TemplateField> 
         <asp:TemplateField HeaderText="Theme" SortExpression="ThemeID"> 
          <ItemTemplate> 
           <asp:DropDownList ID="ThemesIDDropDownList" runat="server" DataSourceID="ThemesSqlDataSource" DataTextField="Theme" DataValueField="ID" CssClass="ddl" SelectedValue='<%# Bind("ThemeID", "{0:D}") %>' AutoPostBack="True"></asp:DropDownList> 
          </ItemTemplate> 
          <FooterTemplate> 
           <asp:DropDownList ID="ThemesIDDropDownList1" runat="server" DataSourceID="ThemesSqlDataSource" DataTextField="Theme" DataValueField="ID" CssClass="ddl" ></asp:DropDownList> 
          </FooterTemplate> 
         </asp:TemplateField> 
         <asp:TemplateField HeaderText="Env" SortExpression="EnvironmentID"> 
          <ItemTemplate> 
           <asp:DropDownList ID="EnvironmentsIDDropDownList" runat="server" DataSourceID="EnvironmentsSqlDataSource" DataTextField="Environment" DataValueField="ID" CssClass="ddl" SelectedValue='<%# Bind("EnvironmentID", "{0:D}") %>' AutoPostBack="True"></asp:DropDownList> 
          </ItemTemplate> 
          <FooterTemplate> 
           <asp:DropDownList ID="EnvironmentsIDDropDownList1" runat="server" DataSourceID="EnvironmentsSqlDataSource" DataTextField="Environment" DataValueField="ID" CssClass="ddl"></asp:DropDownList> 
          </FooterTemplate> 
        </asp:TemplateField> 
        </Columns> 
       </asp:GridView> 
+0

你可以分享GridView的完整標記嗎? –

+0

更新的原始帖子 –

回答

0

的FooterTemplate不與數據源的GridView的每一行呈現,因此它不能結合使用模板。我認爲你應該通過代碼手動完成。你可以檢查這個鏈接DropDownList control inside the GridView FooterTemplate

+0

我不明白你的意思是「FooterTemplate沒有呈現每行」 –

+0

對不起,我犯了一個打字錯誤。我編輯了我的答案,請檢查 –

+0

我發現問題。還有另一個TemplateField,它們的DataRow和FooterRow都具有相同的ID。 –