如何在DATAGRID设置一个模板列然后在模板列邦定邦定DATAGRID动态提出数据,谢谢 在 DataBind 的事件里面再绑定 DataGrid 的数据. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 NekChan(骑蜗牛看星星)能举个实力吗?我才接触.net3个月,谢谢你啊````````````` // Bind DataGrid --Beginfor (int i=0; i<this.dlList.Items.Count; i++){ Label lblFloor = this.dlList.Items[i].FindControl("lblFloor") as Label; DataGrid dgList = this.dlList.Items[i].FindControl("dgList") as DataGrid; // 隐藏显示 DataGrid 列 for (int j=0; j<dgList.Columns.Count; j++) { if (j <= MonthEndDay) { dgList.Columns[j].Visible = true; } else { dgList.Columns[j].Visible = false; } } DataTable dtTemp = new DataTable(); dtTemp = dtBug.Clone(); DataRow[] drDataGrid = dtBug.Select("FloorDesc='" + lblFloor.Text + "'", "BugDesc"); foreach (DataRow dr in drDataGrid) { dtTemp.ImportRow(dr); } DataRow[] drSample = dtSample.Select("FloorDesc='" + lblFloor.Text + "'", "BugCode"); foreach (DataRow dr in drSample) { dtTemp.ImportRow(dr); } dgList.DataSource = dtTemp; dgList.DataBind();}// Bind DataGrid --End 头痛啊,我太菜了,看起头痛,谢谢你啊``````````NekChan(骑蜗牛看星星) 大哥!hanchi8008(寒池) 大哥,我就是不OK啊`````!555555555555555 我是在DATAGRID 里建立一个模板列,在模版列里加入的一个DATAGRID在视图状态下进行的```````5555555555555555!private void Get_Classname() { GetUser_Info username=new GetUser_Info(); string user=username.GetUserName();//获取登陆者名称给创建者名称 SqlConnection myConnection = new SqlConnection(ConnectionString);//取连接字符串,建立连接 SqlDataAdapter SqlDataAdapter1 = new SqlDataAdapter(); SqlDataAdapter1.SelectCommand=new SqlCommand("SELECT * FROM grbg_gyjh_class where cruser='"+user.Trim()+"' ORDER BY id DESC ",myConnection); DataSet DataSet1=new DataSet(); try { SqlDataAdapter1.Fill(DataSet1,"grbg_gyjh_class"); MyDataGrid_Get_Gzjh_big.DataSource=DataSet1; MyDataGrid_Get_Gzjh_big.DataBind(); //以下是邦定子DATAGRID myConnection.Close(); myConnection.Open(); SqlDataAdapter SqlDataAdapter2 = new SqlDataAdapter(); SqlDataAdapter2.SelectCommand=new SqlCommand("SELECT * FROM grbg_gzjh_id where grbg_gzjh_user='"+user.Trim()+"' ORDER BY id DESC ",myConnection); DataSet DataSet2=new DataSet(); try { SqlDataAdapter2.Fill(DataSet2,"grbg_gzjh_id"); MyDataGrid_Get_Gzjh_samll.DataSource=DataSet2; MyDataGrid_Get_Gzjh_samll.DataBind(); } catch(SqlException e2) { myConnection.Close(); } finally { myConnection.Close(); } } catch (SqlException e1) { Response.Write("数据库操作错误:"+e1.Message); }// 在此处放置用户代码以初始化页面 finally { //关闭数据库连接 myConnection.Close(); } } 我也知道我这样肯定不对,因为我把protected System.Web.UI.WebControls.DataGrid MyDataGrid_Get_Gzjh_samll;加到引用里,在视图状态下,就看见模板列中的MyDataGrid_Get_Gzjh_samll就报错了,说已经存在了但是不要这句话,生成的时候又要说MyDataGrid_Get_Gzjh_samll未引用实列`~!头痛啊,是不是必须建用户控件啊`````````` 建用户控件可能会简单点注意把传进去的分类ID使用ViewState 保存既可 哪位大侠有asp.net的图片上传带百分比进度条的源代码!!!!!!! 自定义窗口?? EnterpriseLibrary操作Oracle数据库的事务问题 关于用户自定义控件中显示信息的换行问题 求一批量生成卡号和密码的代码! 请教:asp和几个asp.net的项目怎么合并?详情请进,解决就给50分 关于dropdownlist的小问提 SQL server认证问题 DataGrid 中动态创建控件的问题。 webform弹出模态对话框gridview丢失easyui-datagrid样式 数据库中插入数据问题 我这个是关于asp.net+水晶报表中调用存储过程----好急
能举个实力吗?
我才接触.net3个月,谢谢你啊`````````````
for (int i=0; i<this.dlList.Items.Count; i++)
{
Label lblFloor = this.dlList.Items[i].FindControl("lblFloor") as Label;
DataGrid dgList = this.dlList.Items[i].FindControl("dgList") as DataGrid; // 隐藏显示 DataGrid 列
for (int j=0; j<dgList.Columns.Count; j++)
{
if (j <= MonthEndDay)
{
dgList.Columns[j].Visible = true;
}
else
{
dgList.Columns[j].Visible = false;
}
} DataTable dtTemp = new DataTable();
dtTemp = dtBug.Clone(); DataRow[] drDataGrid = dtBug.Select("FloorDesc='" + lblFloor.Text + "'", "BugDesc");
foreach (DataRow dr in drDataGrid)
{
dtTemp.ImportRow(dr);
} DataRow[] drSample = dtSample.Select("FloorDesc='" + lblFloor.Text + "'", "BugCode");
foreach (DataRow dr in drSample)
{
dtTemp.ImportRow(dr);
}
dgList.DataSource = dtTemp;
dgList.DataBind();
}
// Bind DataGrid --End
谢谢你啊``````````NekChan(骑蜗牛看星星) 大哥!
hanchi8008(寒池)
大哥,我就是不OK啊`````!555555555555555
在视图状态下进行的```````5555555555555555!
private void Get_Classname()
{
GetUser_Info username=new GetUser_Info();
string user=username.GetUserName();//获取登陆者名称给创建者名称 SqlConnection myConnection = new SqlConnection(ConnectionString);//取连接字符串,建立连接
SqlDataAdapter SqlDataAdapter1 = new SqlDataAdapter();
SqlDataAdapter1.SelectCommand=new SqlCommand("SELECT * FROM grbg_gyjh_class where cruser='"+user.Trim()+"' ORDER BY id DESC ",myConnection);
DataSet DataSet1=new DataSet();
try
{ SqlDataAdapter1.Fill(DataSet1,"grbg_gyjh_class");
MyDataGrid_Get_Gzjh_big.DataSource=DataSet1;
MyDataGrid_Get_Gzjh_big.DataBind();
//以下是邦定子DATAGRID
myConnection.Close();
myConnection.Open();
SqlDataAdapter SqlDataAdapter2 = new SqlDataAdapter();
SqlDataAdapter2.SelectCommand=new SqlCommand("SELECT * FROM grbg_gzjh_id where grbg_gzjh_user='"+user.Trim()+"' ORDER BY id DESC ",myConnection);
DataSet DataSet2=new DataSet();
try
{
SqlDataAdapter2.Fill(DataSet2,"grbg_gzjh_id");
MyDataGrid_Get_Gzjh_samll.DataSource=DataSet2;
MyDataGrid_Get_Gzjh_samll.DataBind();
}
catch(SqlException e2)
{
myConnection.Close();
}
finally
{
myConnection.Close();
}
}
catch (SqlException e1)
{
Response.Write("数据库操作错误:"+e1.Message);
}// 在此处放置用户代码以初始化页面
finally
{ //关闭数据库连接
myConnection.Close();
}
}
我也知道我这样肯定不对,因为我把protected System.Web.UI.WebControls.DataGrid MyDataGrid_Get_Gzjh_samll;加到引用里,在视图状态下,就看见模板列中的MyDataGrid_Get_Gzjh_samll就报错了,说已经存在了
但是不要这句话,生成的时候又要说MyDataGrid_Get_Gzjh_samll未引用实列`~!
头痛啊,是不是必须建用户控件啊``````````