本文介绍了将新的空行添加到gridview控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请有人告诉我如何在gridview顶部添加一个新的空行,并且它应该是可编辑的,并且还可以在gridview顶部添加数据。 />


谢谢和问候,

amol

Hi,
please some one tell me how to add a new empty row at the top of the gridview and also it should be editable and also add the data at the top of gridview.

Thanks and regards,
amol

推荐答案

AmolNagrkar写道:
AmolNagrkar wrote:

在gridview顶部添加数据

add the data at the top of gridview



根据您在代码库中的选择进行调整上面。


Adjust this according to your choice in the codebase above.


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //This is a Test Condition
        if (e.Row.RowIndex % 2==0)
        {
            GridViewRow g = new GridViewRow(-1,-1, DataControlRowType.DataRow, DataControlRowState.Normal);
            for (int i = 0; i < e.Row.Cells.Count; i++)
            {
                //creating table Cells
                TableCell tCell = new TableCell();
                tCell.Text = "&nbsp;";
                //Add Cells
                g.Cells.Add(tCell);
                //Set Color for Empty Cell
                g.BackColor = System.Drawing.Color.Red;
            }
            Table tbl = e.Row.Parent as Table;
            //add rows
            tbl.Rows.Add(g);
        }
    }



这篇关于将新的空行添加到gridview控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 23:03
查看更多