在asp.net中创建动态gridview控件 [英] Creating Dynamic gridview control in asp.net

查看:54
本文介绍了在asp.net中创建动态gridview控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

我有桌子,其中可能有行数和

这些行我想在gridview或formview或其他任何你认为足够的行中显示。

这个每列会有三列更多。

就像:



步骤是喜欢来自sql表的标题(我们不知道有多少步骤)



并且对于每个步骤将有3列,用户将添加man manlyly

就像使用数据表的动态行一样。



Dear,
I have table in which there may be number of rows and
this rows I want to show in gridview or formview or any else whatever sufficient you think.
for this each column there will be three columns more.
Just like:

The Steps are like caption which are coming from sql table(We don''t know how many steps are there)

And For each steps there will be 3 columns and user will add the rows manully
just like dynamic rows using datatable.

  STEP1                            STEP2                      STEP3
column1 column2 column3   column1 column2 column3     column1 column2 column3



我们可以像这样创建。

如果是,请告诉我如何做到这一点。





谢谢


Can we create like this.
If yes, please give me an idea how to do this.


Thank you

推荐答案

在Gridview行创建的事件中你有写这样的



On Gridview row created event you have to write like this

protected void Gridview1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            GridView HeaderGrid = (GridView)sender;
            GridViewRow HeaderGridRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
            TableCell HeaderCell = new TableCell();
            HeaderCell.Text = "STEP1";
            HeaderCell.ColumnSpan = 3;            
            HeaderGridRow.Cells.Add(HeaderCell);

            HeaderCell = new TableCell();
            HeaderCell.Text = "STEP2";
            HeaderCell.ColumnSpan = 3;            
            HeaderGridRow.Cells.Add(HeaderCell);

            HeaderCell = new TableCell();
            HeaderCell.Text = "STEP3";
            HeaderCell.ColumnSpan = 3;            
            HeaderGridRow.Cells.Add(HeaderCell);
           

            Gridview1.Controls[0].Controls.AddAt(0, HeaderGridRow);

        }
    }


这篇关于在asp.net中创建动态gridview控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆