日期:2014-05-17  浏览次数:20863 次

将excel显示到页面上 我已经读取了datatable 但是gridview不好用 谁能给个不用插件的啊 直接显示的 谢啦
rt  求帮助啊  新手 没用过c#
------解决方案--------------------
ASPX:
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
            <Columns>
                <asp:BoundField DataField="c1" HeaderText="C1" />
                <asp:BoundField DataField="c2" HeaderText="C2" />
                <asp:BoundField DataField="c3" HeaderText="C3" />
            </Columns>
        </asp:GridView>
    
    </div>
    </form>
</body>

CS:
    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("c1", typeof(string));
                dt.Columns.Add("c2", typeof(string));
                dt.Columns.Add("c3", typeof(string));

                dt.Rows.Add("A", "B", "C");
                dt.Rows.Add("AA", "BB", "CC");

                this.GridView1.DataSource = dt;
                this.GridView1.DataBind();
            }
        }