Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.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
C# 通过单击超链接(不是加号和减号)在gridview中展开和折叠_C#_Asp.net - Fatal编程技术网

C# 通过单击超链接(不是加号和减号)在gridview中展开和折叠

C# 通过单击超链接(不是加号和减号)在gridview中展开和折叠,c#,asp.net,C#,Asp.net,有人能帮我写代码,通过点击超链接在Gridview中展开和折叠吗。 我们有一个有多列的网格。我们在网格中间有一个CououMn,整个列是一个超链接。表示带有超链接的数字。我想为该列编写展开和折叠代码。在中间,我们不能保留任何符号,如负号和加号 <asp:GridView ID="grdrequisitions" runat="server" AutoGenerateColumns="false" AllowPaging="True" OnPageIndexChanging="grd

有人能帮我写代码,通过点击超链接在Gridview中展开和折叠吗。 我们有一个有多列的网格。我们在网格中间有一个CououMn,整个列是一个超链接。表示带有超链接的数字。我想为该列编写展开和折叠代码。在中间,我们不能保留任何符号,如负号和加号

<asp:GridView ID="grdrequisitions" runat="server"
    AutoGenerateColumns="false" AllowPaging="True" OnPageIndexChanging="grdrequisitions_PageIndexChanging"
    OnRowCommand="grdrequisitions_RowCommand"
    CssClass="table table-hover table-bordered table-striped table-page new-table" ShowHeaderWhenEmpty="True" PageSize="15" EmptyDataText="No records found" class="WordWrap">
    <Columns>
    <asp:TemplateField>
        <ItemTemplate>
            <asp:CheckBox ID="chkRow" runat="server" AutoPostBack="True" OnCheckedChanged="ChkSelectChanged" onclick="CheckBoxCheck(this);" />
        </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="WorkforcePlanStatus" HeaderText="Status" />  <%--1--%>
    <asp:BoundField DataField="WorkforcePlanID" HeaderText="WFP ID" HtmlEncode="false" />  <%--2--%>
    <asp:BoundField DataField="CRMOpportunityCode" HeaderText="O2R ID" />   <%--3--%>
    <asp:BoundField DataField="DeliveryUnit" HeaderText="Delivery Unit" /> <%--4--%>
    <asp:BoundField DataField="CustomerAccount" HeaderText="Account" /> <%--5--%>
    <asp:TemplateField HeaderText="# Openings"> <%--6--%>

    <ItemTemplate>
       <asp:LinkButton ID="lnkTotalHeadCount" Style="color: #0000b3;"
           runat="server"
           CausesValidation="false"
           CommandName="TotalHeadCount"
           Text='<%# Eval("TotalHeadCount") %>'
           CommandArgument='<%# Eval("WorkforcePlanID") %>'
           EnableTheming="False">                                                   
     </asp:LinkButton>
     </ItemTemplate>
     </asp:TemplateField>


这是代码。我必须为
ID=“lnkTotalHeadCount”
编写展开和折叠代码。请帮我试试下面的代码。希望它能回答你的问题

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">


<script type="text/javascript">
    function toggleColumn(link)
    {
        var div = $(link).siblings('.countDiv');
        //alert(div.length);
        $(div).toggle();
    }
</script>

<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server">
    <Columns>
        <asp:TemplateField HeaderText="# Openings"> 
<ItemTemplate>
    <a style="cursor:pointer;" onclick="toggleColumn(this)"><%# Eval("Count") %></a>      
    <div class="countDiv">
        Total Count: 20
    </div>
 </ItemTemplate>
 </asp:TemplateField>
    </Columns>
</asp:GridView>

函数切换列(链接)
{
var div=$(link.sibbines('.countDiv');
//警报(分区长度);
$(div.toggle();
}
总数:20

Default.aspx.cs文件:

  namespace aspnetWeb
      {
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<Student> list = new List<Student>();

            for(int i=1;i<=10;i++)
            list.Add(new Student { ID = 1, Count = 20 });

            GridView1.DataSource = list.AsQueryable();
            GridView1.DataBind();
        }
    }

    public class Student
    {
        public int ID { get; set; }

        public int Count { get; set; }
    }
 }
名称空间aspnetWeb
{
公共部分类\u默认值:第页
{
受保护的无效页面加载(对象发送方、事件参数e)
{
列表=新列表();
对于(int i=1;i