gridview 加控件表头(在后台并保留原先的表头)在GridView1_RowCreated的事件中写
1.
if (e.Row.RowType == DataControlRowType.Header)//如果创建的是表头
{
//GridViewRow rowHeader = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);//表头行
//int i = 0;
////数据库中的表 Y_LNSR 的列名
//string sql = "select name from syscolumns where id=object_id('" + DropDownList2.SelectedValue + "')";
//DataSet ds = new DataSet();
//ds = DBArticle.RunSqlDs(sql);
//DataRow row = ds.Tables[0].NewRow();
//row["name"] = "--请选择--";
//ds.Tables[0].Rows.InsertAt(row, 0);
//TableCellCollection tcl = e.Row.Cells;//获得表头元素的实例
//foreach (TableCell item in tcl)
//{
// TableHeaderCell cell = new TableHeaderCell();
// DropDownList dro = new DropDownList();
// dro.ID = "dro" + i.ToString();
// dro.DataSource = ds.Tables[0].DefaultView;
// dro.DataTextField = ds.Tables[0].Columns[0].ColumnName;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载