土法合并GridView表頭

來源:互聯網
上載者:User

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
this.style.display='none'; Codehighlighter1_79_2007_Open_Text.style.display='none'; Codehighlighter1_79_2007_Closed_Image.style.display='inline'; Codehighlighter1_79_2007_Closed_Text.style.display='inline';
}" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" alt="" align="top">{
this.style.display='none'; Codehighlighter1_79_2007_Closed_Text.style.display='none'; Codehighlighter1_79_2007_Open_Image.style.display='inline'; Codehighlighter1_79_2007_Open_Text.style.display='inline';
}" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" alt="" align="top">    {
        if (e.Row.RowType == DataControlRowType.Header)
{
this.style.display='none'; Codehighlighter1_145_2001_Open_Text.style.display='none'; Codehighlighter1_145_2001_Closed_Image.style.display='inline'; Codehighlighter1_145_2001_Closed_Text.style.display='inline';
}" src="http://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" alt="" align="top">{
this.style.display='none'; Codehighlighter1_145_2001_Closed_Text.style.display='none'; Codehighlighter1_145_2001_Open_Image.style.display='inline'; Codehighlighter1_145_2001_Open_Text.style.display='inline';
}" src="http://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif" alt="" align="top">        {
            //因為自訂表格頭,所以原來系統中實現的排序功能就失效了需自行實現排序功能

            TableCellCollection myTcl = e.Row.Cells;
            //清除自動產生的表頭
            myTcl.Clear();

            //添加新的表頭
            Label l1 = new Label();
            l1.Text = "序號";
            myTcl[0].Controls.Add(l1);

            myTcl.Add(new TableHeaderCell());
            myTcl[1].RowSpan = 2;
            myTcl[1].Text = "進口料件</br>品名";
            myTcl[1].Width = 150;

            myTcl.Add(new TableHeaderCell());
            myTcl[2].ColumnSpan = 2;
            myTcl[2].Text = "成品1";

            myTcl.Add(new TableHeaderCell());
            myTcl[3].ColumnSpan = 2;
            myTcl[3].Text = "成品2";

            myTcl.Add(new TableHeaderCell());
            myTcl[4].ColumnSpan = 2;
            myTcl[4].Text = "成品3";

            myTcl.Add(new TableHeaderCell());
            myTcl[5].ColumnSpan = 2;
            myTcl[5].Text = "成品4";

            myTcl.Add(new TableHeaderCell());
            myTcl[6].ColumnSpan = 2;
            myTcl[6].Text = "成品5";

            myTcl.Add(new TableHeaderCell());
            myTcl[7].ColumnSpan = 2;
            myTcl[7].Text = "成品6";

            myTcl.Add(new TableHeaderCell());
            myTcl[8].ColumnSpan = 2;
            myTcl[8].Text = "成品7";

            myTcl.Add(new TableHeaderCell());
            myTcl[9].ColumnSpan = 2;
            myTcl[9].Text = "成品8";

            myTcl.Add(new TableHeaderCell());
            myTcl[10].RowSpan = 2;
            myTcl[10].Text = "操作";

            //以下為新增第二列名,原理有些類似於SQL注入攻擊
            myTcl.Add(new TableHeaderCell());
            myTcl[11].ColumnSpan = 1;
            myTcl[11].Text = "<tr><th>單耗</th><th>損耗</th><th>單耗</th><th>損耗</th><th>單耗</th><th>損耗</th><th>單耗</th><th>損耗</th><th>單耗</th><th>損耗</th><th>單耗</th><th>損耗</th><th>單耗</th><th>損耗</th><th>單耗</th><th>損耗</th>";

        }
    }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.