Hi,
I need a output grid like this
While loading page ...
Table 1 companyid(primarykey), companyname
Table 2 product_id, product_name, Company_id
___________________________________________________________
Product_ID Product_Name Company_ID Check_Box Button
--------------------------------------------------------------------
1 brush dropdownbox checkbox clickbutton
2 pin dropdownbox checkbox clickbutton
In dropdowbox the company id should be loaded, while page loading the table 2 grid view is load with the custom column, If the particular checkbox checked and button is clicked then the selected id company name will be displayed at the bottom in a new grid.
Loading

Sudhakar ChaudharyRank #1,379 · 1.2K reputationPosted Feb 20, 2012, 9:41 PM EST
newto net58 reputationPosted Feb 21, 2012, 4:52 PM EST
newto net58 reputationPosted Feb 26, 2012, 7:14 AM EST
newto net58 reputationPosted Feb 26, 2012, 8:30 PM EST
rashmi kc89 reputationPosted Jul 21, 2012, 10:25 PM EDT
I need to move data from one gridview into another when the button is press
how to do this
Sudhakar ChaudharyRank #1,379 · 1.2K reputationPosted Jul 21, 2012, 11:40 PM EDT
if any problem see the give attachment file.
thank you.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data.OleDb;
namespace cornerGrid
{
public partial class Form1 : Form
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\dbs.accdb;Persist Security Info=False");
public Form1()
{
InitializeComponent();
}
private void GridColumn(DataGridView grid)
{
try
{
grid.Columns.Add("", "Name");
grid.Columns.Add("", "Address");
grid.Columns.Add("", "Phone");
grid.Columns.Add("", "Email");
grid.DefaultCellStyle.Font = new Font("Calibri", 11, FontStyle.Regular);
grid.ColumnHeadersDefaultCellStyle.Font = new Font("Calibri", 11.25f, FontStyle.Bold);
DataGridViewCellStyle fooCellStyle = new DataGridViewCellStyle();
DataGridViewHeaderCell f = new DataGridViewHeaderCell();
grid.ColumnHeadersDefaultCellStyle.BackColor = Color.BurlyWood;
grid.ColumnHeadersDefaultCellStyle.ForeColor = Color.Black;
grid.DefaultCellStyle.ForeColor = Color.Black;
grid.EnableHeadersVisualStyles = false;
grid.Columns[0].Width = 200;
grid.Columns[1].Width = 200;
grid.Columns[3].Width = 200;
grid.RowHeadersVisible = false;
}
catch (Exception) { }
}
private void FillGrid(DataGridView grid)
{
try
{
OleDbDataAdapter adp = new OleDbDataAdapter("select * from tables",conn);
DataSet ds = new DataSet();
adp.Fill(ds, "s");
for (int i = 0; i < ds.Tables["s"].Rows.Count; i++)
{
grid.Rows.Add();
grid.Rows[i].Cells[0].Value = ds.Tables["s"].Rows[i].ItemArray[0];
grid.Rows[i].Cells[1].Value = ds.Tables["s"].Rows[i].ItemArray[1];
grid.Rows[i].Cells[2].Value = ds.Tables["s"].Rows[i].ItemArray[2];
grid.Rows[i].Cells[3].Value = ds.Tables["s"].Rows[i].ItemArray[3];
}
}
catch (Exception ms) { MessageBox.Show(ms.ToString()); }
}
private void Form1_Load(object sender, EventArgs e)
{
GridColumn(dataGridView1);
GridColumn(dataGridView2);
FillGrid(dataGridView1);
}
private void button1_Click(object sender, EventArgs e)
{
FillGrid(dataGridView2);
}
}
}
rashmi kc89 reputationPosted Jul 22, 2012, 12:09 AM EDT
Sudhakar ChaudharyRank #1,379 · 1.2K reputationPosted Jul 22, 2012, 1:20 AM EDT
{
dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (Convert.ToBoolean(dataGridView1.Rows[e.RowIndex].Cells[4].Value) == true)
{
int rows = dataGridView2.Rows.Count;
dataGridView2.Rows.Add();
dataGridView2.Rows[rows - 1].Cells[0].Value = dataGridView1.CurrentRow.Cells[0].Value;
dataGridView2.Rows[rows - 1].Cells[1].Value = dataGridView1.CurrentRow.Cells[1].Value;
dataGridView2.Rows[rows - 1].Cells[2].Value = dataGridView1.CurrentRow.Cells[2].Value;
dataGridView2.Rows[rows - 1].Cells[3].Value = dataGridView1.CurrentRow.Cells[3].Value;
}
}