我正在尝试在同一页面上将详细信息从一个gridview添加到另一个gridview;但是我没有看到gridview(不可见)。不确定究竟是什么原因导致因为在属性窗口中将visible设置为true。
protected void btnAssign_Click(object sender, EventArgs e)
{
DataRow drow;
DataTable dt = SetDataTable();
drow = dt.NewRow();
//GridView1.Rows.Add(1);
int row = GridView1.Rows.Count - 1;
drow["Customer Name"] = GridView1.Rows[row].Cells[0].Text;
drow["Invoice #"] = GridView1.Rows[row].Cells[1].Text;
drow["Invoice Qty"] = GridView1.Rows[row].Cells[2].Text;
//drow["Salary"] = textBox4.Text.Trim();
dt.Rows.Add(drow);
BindGrid(dt);
btnDelete.Visible = true;
}
private DataTable SetDataTable()
{
DataTable dt = new DataTable();
try
{
DataColumn dcol = new DataColumn("Customer Name", typeof(System.String));
dt.Columns.Add(dcol);
dcol = new DataColumn("Invoice #", typeof(System.String));
dt.Columns.Add(dcol);
dcol = new DataColumn("Invoice Qty", typeof(System.String));
dt.Columns.Add(dcol);
}
catch (Exception ex)
{
}
return dt;
}
private void BindGrid(DataTable dt)
{
try
{
if (dt.Rows.Count > 0)
{
GridView2.DataSource = dt;
}
else { }
}
catch (Exception ex)
{
}
}