我有两个gridview并且分别有一个linkbutton,第二个gridview的数据为固定列和动态添加的模板列,当点击第
//动态添加模板列的接口//动态添加模板列的接口中的固定列privateDataTableCreateBaseDataSource(){DataTabledt=newDa...
//动态添加模板列的接口
//动态添加模板列的接口中的固定列
private DataTable CreateBaseDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
ds.Clear();
ds = mrp.fillDataSet("select a.id,a.xid,b.order_no,a.item,a.number,a.Materials,a.Unit,b.Command_no,a.ChargeMan,b.StartDate,b.FinishDate from o_orderNoDetail as a,o_OrderNo as b where a.OrderID='" + lblorderid.Text.Trim() + "'and b.id='" + lblorderid.Text.Trim() + "'");
DataTable dt_1 = ds.Tables[0];
TimeSpan ts = dt_end - dt_start;
int days = ts.Days + 1;
Label1.Text = Convert.ToString(days);
dt.Columns.Add(new DataColumn("xid", typeof(Int32)));
dt.Columns.Add(new DataColumn("item", typeof(string)));
dt.Columns.Add(new DataColumn("number", typeof(string)));
dt.Columns.Add(new DataColumn("Materials", typeof(string)));
dt.Columns.Add(new DataColumn("Unit", typeof(string)));
dt.Columns.Add(new DataColumn("StartDate", typeof(string)));
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
dr = dt.NewRow();
dr["xid"] = dt_1.Rows[i]["xid"];
dr["item"] = dt_1.Rows[i]["item"];
dr["number"] = dt_1.Rows[i]["number"];
dr["Materials"] = dt_1.Rows[i]["Materials"];
dr["Unit"] = dt_1.Rows[i]["Unit"];
DateTime dt_start3 = Convert.ToDateTime(dt_1.Rows[i]["StartDate"]);
string month3 = Convert.ToString(dt_start3.Month);
string day3 = Convert.ToString(dt_start3.Day);
dr["StartDate"] = month3 + "月" + day3 + "日";
dt.Rows.Add(dr);
}
return dt;
}
点击第一个gridview执行
protected void gvOrder_RowCommand(object sender, GridViewCommandEventArgs e)
{
//查看订单下的图纸状态
if (e.CommandName == "view")
{
gvDraws.DataSource = CreateBaseDataSource().DefaultView;
gvDraws.DataBind();
}
当点击第一个的linkbutton时,第二个gridview中的linkbutton的值消失了 展开
//动态添加模板列的接口中的固定列
private DataTable CreateBaseDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
ds.Clear();
ds = mrp.fillDataSet("select a.id,a.xid,b.order_no,a.item,a.number,a.Materials,a.Unit,b.Command_no,a.ChargeMan,b.StartDate,b.FinishDate from o_orderNoDetail as a,o_OrderNo as b where a.OrderID='" + lblorderid.Text.Trim() + "'and b.id='" + lblorderid.Text.Trim() + "'");
DataTable dt_1 = ds.Tables[0];
TimeSpan ts = dt_end - dt_start;
int days = ts.Days + 1;
Label1.Text = Convert.ToString(days);
dt.Columns.Add(new DataColumn("xid", typeof(Int32)));
dt.Columns.Add(new DataColumn("item", typeof(string)));
dt.Columns.Add(new DataColumn("number", typeof(string)));
dt.Columns.Add(new DataColumn("Materials", typeof(string)));
dt.Columns.Add(new DataColumn("Unit", typeof(string)));
dt.Columns.Add(new DataColumn("StartDate", typeof(string)));
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
dr = dt.NewRow();
dr["xid"] = dt_1.Rows[i]["xid"];
dr["item"] = dt_1.Rows[i]["item"];
dr["number"] = dt_1.Rows[i]["number"];
dr["Materials"] = dt_1.Rows[i]["Materials"];
dr["Unit"] = dt_1.Rows[i]["Unit"];
DateTime dt_start3 = Convert.ToDateTime(dt_1.Rows[i]["StartDate"]);
string month3 = Convert.ToString(dt_start3.Month);
string day3 = Convert.ToString(dt_start3.Day);
dr["StartDate"] = month3 + "月" + day3 + "日";
dt.Rows.Add(dr);
}
return dt;
}
点击第一个gridview执行
protected void gvOrder_RowCommand(object sender, GridViewCommandEventArgs e)
{
//查看订单下的图纸状态
if (e.CommandName == "view")
{
gvDraws.DataSource = CreateBaseDataSource().DefaultView;
gvDraws.DataBind();
}
当点击第一个的linkbutton时,第二个gridview中的linkbutton的值消失了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询