Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将footertemplate添加到gridview中,并选择展开和折叠数据行?C#/ASP.NET_C#_Asp.net_Gridview_Expand_Collapse - Fatal编程技术网

如何将footertemplate添加到gridview中,并选择展开和折叠数据行?C#/ASP.NET

如何将footertemplate添加到gridview中,并选择展开和折叠数据行?C#/ASP.NET,c#,asp.net,gridview,expand,collapse,C#,Asp.net,Gridview,Expand,Collapse,您好,我想制作一个页脚模板,可以展开和折叠结果,如其他主题中的图像示例: 我想要默认显示1个结果,在点击footertemplate上的图标后显示更多结果,如4或5,我可以显示代码,提前感谢。这会很容易 在GridView中激活“AllowPaging” 使分页行不可见 在每次单击图标时,增加“PageSize”以进行展开,或单击另一个图标时减少“PageSize”以进行折叠 我在我的项目上做的同样的工作!我正在把那份工作贴在这里。请仔细检查一下,它可能会帮助你解决问题 ASPX: <as

您好,我想制作一个页脚模板,可以展开和折叠结果,如其他主题中的图像示例:

我想要默认显示1个结果,在点击footertemplate上的图标后显示更多结果,如4或5,我可以显示代码,提前感谢。

这会很容易

  • 在GridView中激活“AllowPaging”
  • 使分页行不可见
  • 在每次单击图标时,增加“PageSize”以进行展开,或单击另一个图标时减少“PageSize”以进行折叠

  • 我在我的项目上做的同样的工作!我正在把那份工作贴在这里。请仔细检查一下,它可能会帮助你解决问题
    ASPX:

    <asp:GridView Width="100%" border="1" ID="gwProfit" RowStyle-Wrap="true" runat="server" AutoGenerateColumns="false" AlternatingRowStyle-CssClass="alternaterow" RowStyle-VerticalAlign="Bottom" ShowFooter="True" HeaderStyle-Wrap="true" OnRowCommand="gwProfit_RowCommand" OnRowDataBound="gwProfit_RowDataBound">
        <Columns>
        <asp:TemplateField HeaderText="Start Date">
        <ItemTemplate>
        <div class="input-append">
        <asp:TextBox class="input_disabled" ID="txtStartDate" runat="server" Width="110px"  Height="22px" Text='<%# Bind("StartDate","{0}") %>'>
        </asp:TextBox>
         <button class="btn123" ID="ImgStartDate" runat="server" type="button" style="height:25px;">
         <i class="icon-calendar"></i>
         </button>
         </div>
               <ajaxToolkit:CalendarExtender ID="StartDate" runat="server" TargetControlID="txtStartDate" PopupButtonID="ImgStartDate" Format="dd-MMM-yyyy">
                </ajaxToolkit:CalendarExtender>
                 </ItemTemplate>
                 <FooterTemplate>
                <asp:TextBox class="input_disabled" ID="txtNewStartDate" runat="server" Width="110px"  Height="22px">
                </asp:TextBox>
                <button class="btn123" ID="ImgStartDate" runat="server" type="button" style="height:25px;">
                <i class="icon-calendar"></i>
                </button>
                </div>
    
                <ajaxToolkit:CalendarExtender ID="StartDate" runat="server" TargetControlID="txtNewStartDate" 
                PopupButtonID="ImgStartDate" Format="dd-MMM-yyyy">
                </ajaxToolkit:CalendarExtender>
                </FooterTemplate>
               </asp:TemplateField>
    
             <asp:TemplateField HeaderText="End Date">
             <ItemTemplate> 
                           <asp:TextBox class="input_disabled" ID="txtEndDate" runat="server" Width="110px"  Height="22px" Text='<%# Bind("EndDate","{0}") %>'>
    
                        </asp:TextBox>
                        <button class="btn123" ID="ImgEndDate" runat="server" type="button" style="height:25px;">
                        <i class="icon-calendar"></i>
                        </button>
                        <ajaxToolkit:CalendarExtender ID="EndDate" runat="server" TargetControlID="txtEndDate" 
                        PopupButtonID="ImgEndDate" Format="dd-MMM-yyyy">
                        </ajaxToolkit:CalendarExtender>                                  
            </ItemTemplate>
            <FooterTemplate>                       
             <asp:TextBox class="input_disabled" ID="txtNewEndDate" runat="server" Width="110px"  Height="22px">
                        </asp:TextBox>
                        <button class="btn123" ID="ImgEndDate" runat="server" type="button" style="height:25px;">
                        <i class="icon-calendar"></i>
                        </button>
    
                        <ajaxToolkit:CalendarExtender ID="EndDate" runat="server" TargetControlID="txtNewEndDate" 
                        PopupButtonID="ImgEndDate" Format="dd-MMM-yyyy">
                        </ajaxToolkit:CalendarExtender> 
            </FooterTemplate>
            </asp:TemplateField>
    
      <asp:TemplateField HeaderText="Profit Per Unit">
      <ItemTemplate>
    <asp:TextBox class="input_disabled" ID="txtProfitPerUnit" Width="100px"  Height="22px" runat="server" Text='<%# Bind("ProfitPerUnit","{0}") %>'> </asp:TextBox>
      </ItemTemplate>
     <FooterTemplate>
     <asp:TextBox class="input_disabled" ID="txtNewProfitPerUnit" Width="100px" Height="22px" runat="server" Text="0"/>                
     </FooterTemplate>
     </asp:TemplateField>
    
      <asp:TemplateField HeaderText="Action" ControlStyle-Width="14px" FooterStyle-Width="14px">
       <ItemTemplate>
         <input type="hidden" id="txtrec_status" name="txtrec_status" runat="server"/>
    
    <asp:ImageButton ID="btnDelete" runat="server" CommandName="Delete" ImageUrl="~/images/delete.gif" AlternateText="Delete" CommandArgument="<%# ((GridViewRow) Container).RowIndex%>" UseSubmitBehavior="False" />
          </ItemTemplate>
          <FooterTemplate>
           <asp:ImageButton ID="btnAdd" runat="server" CommandName="Add" ImageUrl="~/images/add.png" AlternateText="Add" UseSubmitBehavior="False"/>
            </FooterTemplate>
            </asp:TemplateField>
                 </Columns>
                 </asp:GridView>
    

    与您的解决方案,我有一些错误,你能发送它的功能?很高兴看到你解决了错误!如果有帮助,请将答案标记为“已接受答案”!干杯!:)@抹去
    protected void gwProfit_RowCommand(object sender, GridViewCommandEventArgs e)
        {
    if (ViewState["dtStartDate"] != null)
                 dtStartDate = (DataTable) ViewState["dtStartDate"];
    
            if (e.CommandName.Equals("Add"))
            {
                TextBox txtStartDate = (TextBox)gwProfit.FooterRow.FindControl("txtNewStartDate");
                TextBox txtEndDate = (TextBox)gwProfit.FooterRow.FindControl("txtNewEndDate");
                TextBox txtProfitPerUnit = (TextBox)gwProfit.FooterRow.FindControl("txtNewProfitPerUnit");
                if (txtEndDate.Text == "" || txtStartDate.Text == "" || txtProfitPerUnit.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Please Select Start Date, End Date And Profit Per Unit.')", true);
                }
                else
                {
                    dtStartDate.Rows.Add(dtStartDate.NewRow());
                    dtStartDate.Rows[dtStartDate.Rows.Count - 1]["CurrencyDeatailID"] = -2;
                    dtStartDate.Rows[dtStartDate.Rows.Count - 1]["StartDate"] = objFunc.toDate(txtStartDate.Text);
                    dtStartDate.Rows[dtStartDate.Rows.Count - 1]["EndDate"] = objFunc.toDate(txtEndDate.Text);
                    dtStartDate.Rows[dtStartDate.Rows.Count - 1]["ProfitPerUnit"] = objFunc.toDecimal(txtProfitPerUnit.Text);
                    if (dtStartDate.Rows.Count >= 0&&dtStartDate.Rows[0]["CurrencyDeatailID"].ToString()=="-1")
                    {
                        dtStartDate.Rows[0].Delete();
                        if (dtStartDate.Rows.Count > 0 && dtStartDate.Rows[0].RowState == DataRowState.Deleted)
                            dtStartDate.Rows.RemoveAt(0);
    
                    }
                    ViewState["dtStartDate"] = dtStartDate;
                    Profit_LoadGrid();
                }
            }
            else if (e.CommandName.Equals("Delete"))
            {
                int index = objFunc.toInt(e.CommandArgument.ToString());
                GridViewRow gvr = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
                int RemoveAt = gvr.RowIndex;
                DataTable dt = new DataTable();
                dt = (DataTable)ViewState["dtStartDate"];
                dt.Rows.RemoveAt(RemoveAt);
                dt.AcceptChanges();
                ViewState["dtStartDate"] = dt;
                Profit_LoadGrid();
            }
        }