w!w!w!w!w!!!!!
没人理我吗?TOO EASY?

解决方案 »

  1.   

    /////下面为引用控件的代码,大家快来测试!!!!!
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;namespace CustomDataGridDemo
    {
    /// <summary>
    /// WebForm1 的摘要说明。
    /// </summary>
    public class WebForm1 : System.Web.UI.Page
    {
    protected WebControlLibrary.CustomDataGrid CustomDataGrid1;
    protected DataTable dt;
    protected DataView dataView1; public class MyDataTable
    {
    public DataTable DataTableTmp;

    public MyDataTable()
    {
    DataTable dt = new DataTable();
    DataRow r; dt.Columns.Add("id");
    dt.Columns.Add("column1");
    dt.Columns.Add("column2");
    dt.Columns.Add("column3");
    dt.Columns.Add("column4"); for(int i=1; i<20; i ++)
    {
    r= dt.NewRow(); r["id"] = i.ToString();
    r["column1"] = "Column 1 : " + i.ToString();
    r["column2"] = "Column 2 : " +  i.ToString();
    r["column3"] = "Column 3 : " +  i.ToString();
    r["column4"] = "Column 4 : " +  i.ToString(); dt.Rows.Add(r);

    }
    DataTableTmp = dt;
    } }
    private void Page_Load(object sender, System.EventArgs e)
    {
    // 在此处放置用户代码以初始化页面

    MyDataTable mdt = new MyDataTable();
    dt = mdt.DataTableTmp;
    dataView1 = dt.DefaultView; CustomDataGrid1.DataBind(); 
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion
    }
    }
      

  2.   

    看这段代码,定义datagrid和div
    <div style="OVERFLOW: scroll; HEIGHT: 385px" id="canRollDiv">
    <div id="floatDiv" style="position:absolute;top:expression(this.parentNode.scrollTop);left:expression(this.parentNode.scrollLeft);z-index:1;background:#000000"></div>
    <asp:DataGrid id="DG1List" runat="server" BackColor="#000000" AutoGenerateColumns="False" CellSpacing="1" CellPadding="0" ShowHeader="True" BorderWidth="0" GridLines="both">
    <HeaderStyle BorderStyle="None" BackColor="#F7F7F7" HorizontalAlign="Center"></HeaderStyle>
    <ItemStyle HorizontalAlign="center" BackColor="#ffffff"></ItemStyle>
    <Columns>
    <asp:BoundColumn DataField="jcode" HeaderText="代码" HeaderStyle-Width="25"></asp:BoundColumn>
    <asp:BoundColumn DataField="jname" HeaderText="教师姓名" HeaderStyle-Width="52"></asp:BoundColumn>
    </Columns>
    </asp:DataGrid>
    </div>
    在html页面最后写上
    <script language="javascript">
    <!--
    var obj=document.createElement("TABLE");
    floatDiv.appendChild(obj);
    var objTH=document.createElement("THEAD");
    obj.appendChild(objTH);
    var objTR=DG1List.firstChild.firstChild.cloneNode(true);
    objTH.appendChild(objTR);
    objTR.mergeAttributes(DG1List.firstChild.firstChild);
    for(i=0;i<objTR.childNodes.length;i++)
    {
             objTR.childNodes[i].style.borderWidth="1px";
    objTR.childNodes[i].mergeAttributes  (DG1List.firstChild.firstChild.childNodes[i]);
    }
    obj.style.borderWidth="1px";
    //-->
    </script>
      

  3.   

    问题已解决。DataGridItem item in Controls[0].Controls 错了,应为DataGridItem item in this.Itemswangcl(wangcl) :
        你的方法我已试过,虽可固定表头,但列宽是固定的,不能随列动态调整。
      

  4.   

    哪位大侠有类似AspxGrid功能的控件,能发给我一个吗?最近做项目很急的,谢谢!!!///////////////////////////////////MY EMAIL: [email protected]//////////////////////////////////