PDA

View Full Version : کپی از دیتا گرید ویو



merfi1
سه شنبه 10 بهمن 1391, 12:58 عصر
من از ازدیتا گرید اولی بازدن تیک چک باکسها اونا رو تو دیتا گرید دومی اضافه میکنم اما ردیف اخری روکه تیک میزنم اضافه نمیشه مشکل کجاس اینم کد مورد استفاده: for (int i = 0; i < dataGridView1.RowCount - 1; i++)
{

if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[4].Value) == true)
{
object[] ob = new object[] { dataGridView1.Rows[i].Cells[0].Value, dataGridView1.Rows[i].Cells[1].Value, dataGridView1.Rows[i].Cells[2].Value, dataGridView1.Rows[i].Cells[3].Value };

dataGridView2.Rows.Add(ob);
}

website.expert
سه شنبه 10 بهمن 1391, 13:42 عصر
protected void Button1_Click(object sender, EventArgs e)
{
DataTable dt=new DataTable("Contact");
dt.Columns.Add("ID");
dt.Columns.Add("Name");
dt.Columns.Add("Family");

foreach (DataGridItem item in DataGrid1.Items)
{
CheckBox cb = (CheckBox)item.FindControl("chkSelect");
if (cb != null && cb.Checked)
dt.Rows.Add(item.Cells[0].Text,item.Cells[1].Text,item.Cells[2].Text);
}
DataGrid2.DataSource = dt;
DataGrid2.DataBind();
}