请问C#.net这种效果怎么做出来的?(点+号展开)
请知道的朋友给个源代码 谢谢
图片地址:http://community.kingdee.com/images/www_mykingdee_com/leoch/SRM.jpg

解决方案 »

  1.   

    简单的做法就是treeview,难一点的做法就是js
      

  2.   

    问下这个事cs的还是bs的?cs的话,用dataset可以解决这个问题
      

  3.   

    参考:利用GridView显示主细表并添加打开、关闭功能
    http://dotnet.aspx.cc/article/33e3cfc4-7cf1-48f1-a013-45ff9fa06e03/read.aspx代码:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewNested.aspx.cs" Inherits="Exam_GridViewNested" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      <title>利用GridView显示主细表并添加打开、关闭功能</title>
      <style type="text/css">
      td,div,a {font-size:12px}
      </style>  <script type="text/javascript">
      //<![CDATA[
      function ShowHidden(sid,ev)
      {
        ev = ev || window.event;
        var target = ev.target || ev.srcElement;
        var oDiv = document.getElementById("div" + sid);
        oDiv.style.display = oDiv.style.display == "none"?"block":"none";
        target.innerHTML = oDiv.style.display == "none"?"显示":"隐藏";
      }
      //]]>
      </script></head>
    <body>
      <form id="form1" runat="server">
        <asp:GridView ID="MasterGridView" runat="server" AutoGenerateColumns="false" Width="760px"
          BorderWidth="1" OnRowDataBound="MasterGridView_RowDataBound" DataKeyNames="id"
          ShowHeader="false">
          <Columns>
            <asp:TemplateField>
              <ItemTemplate>
                <div style="width: 100%; padding: 2px; font-weight: bold; background-color: #DEDEDE;
                  float: left">
                  <span style="float: left">栏目名称:<%#Eval("Title") %></span><span style="float: right;
                    color: Red; cursor: pointer" onclick="ShowHidden('<%#Eval("id") %>',event)">隐藏</span></div>
                <div style="background-color: #FFF; padding-left: 60px;clear:both" id="div<%#Eval("id") %>">
                  <asp:GridView ID="DetailGridView" runat="server" AutoGenerateColumns="false" ShowHeader="true"
                    Width="100%" HorizontalAlign="left">
                    <HeaderStyle BackColor="#9999FF" />
                    <Columns>
                      <asp:TemplateField HeaderText="文章名称">
                        <ItemTemplate>
                          <a href="/article/<%#Eval("objectGuid") %>/read.aspx">
                            <%#Eval("Title") %>
                          </a>[<%# Eval("HitCount") %>]
                        </ItemTemplate>
                      </asp:TemplateField>
                      <asp:BoundField HeaderText="发布日期" DataField="CreateDate" HtmlEncode="false" DataFormatString="{0:yyyy年MM月dd日}"
                        ItemStyle-Width="100px" ItemStyle-HorizontalAlign="Center" />
                    </Columns>
                  </asp:GridView>
                </div>
              </ItemTemplate>
            </asp:TemplateField>
          </Columns>
        </asp:GridView>
      </form>
    </body>
    </html>
    .csusing System;
    using System.Data;
    using System.Data.OleDb;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;public partial class Exam_GridViewNested : System.Web.UI.Page
    {
      string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\aspxWeb.mdb;Persist Security Info=True";
      OleDbConnection cn1;
      protected void Page_Load(object sender, EventArgs e)
      {
        if (!Page.IsPostBack)
        {
          OleDbConnection cn = new OleDbConnection(ConnectionString);
          cn.Open();
          cn1 = new OleDbConnection(ConnectionString);
          cn1.Open();
          OleDbCommand cmd = new OleDbCommand("select * from [Subject]", cn);
          OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
          MasterGridView.DataSource = dr;
          MasterGridView.DataBind();
          dr.Close();
          cmd.Dispose();
          cn.Dispose();
          cn1.Dispose();
          cn = cn1 = null;
        }
      }
      protected void MasterGridView_RowDataBound(object sender, GridViewRowEventArgs e)
      {
        if (e.Row.RowType == DataControlRowType.DataRow)
        { 
         
         GridView oGridView = (GridView)e.Row.FindControl("DetailGridView");
         if (oGridView != null)
         {
           OleDbCommand cmd = new OleDbCommand("select top 10 * from Document Where pid = " + MasterGridView.DataKeys[e.Row.RowIndex].Value, cn1);
           OleDbDataReader dr1 = cmd.ExecuteReader();
           oGridView.DataSource = dr1;
           oGridView.DataBind();
           dr1.Close();
           cmd.Dispose();
         }
        }
      }
    }
      

  4.   

    这种表格最好不要用Gridview来写,不太灵活。 建议用Div 配合js. 很简单实现的
      

  5.   

    建议用Div 配合js 怎么写??大虾举个例子吧
      

  6.   

    用Div 配合js. 很简单实现
      

  7.   

    方法很多~~JS+DIV可以
    直接用.net数据控件组合也没有问题的~~
      

  8.   

    JS里面写 function selReply(obj,id)
            {
                if(document.getElementById(id).style.display=="block")
                {
                    document.getElementById(id).style.display="none";
                    obj.src="Images/jia.gif";
                }
                else
                {
                    document.getElementById(id).style.display="block";
                    obj.src="Images/jian.gif";
                }
            }
    在TABLE里面写
    <td style="width: 324px" align="left">
                                           <img src="Images/jia.gif" alt="" onclick="selReply(this,'<%# Eval("ID")  %>')" /><%# Eval("Subject") %>
                                       </td>
      

  9.   

    试试这个控件:http://www.denisbauer.com/ASPNETControls/NestedHierarGridDemo.aspx
      

  10.   

    忘了说了,上面的是示例的地址,控件在这里:http://www.denisbauer.com/ASPNETControls/HierarGrid.aspx
      

  11.   

    就是有点像outlook样式的.
    http://www.codeproject.com/KB/custom-controls/extgridview.aspx
    这个应该可以满足你.
      

  12.   

    有个第三方控件可以达到你要的效果  实现起来很简单    Devexpress 的 AspxGridView
      

  13.   

    我感觉这个用Repeater来做可能简单点。
      

  14.   

    这种表格最好不要用Gridview来写,不太灵活。 建议用Div 配合js. 很简单实现的
      

  15.   

      DIV+JS`两个层控制就OK了··隐藏和显示··