Hello Group,
I have 2 datagrids and the first one is bound to a
database. Each row consists of checkbox, textbox etc.. As the user makes
the selection, I want to add the corresponding row to the other datagrid.
Unable to figure out how to copy rows in DG. Any help would be appreciated!
Thanks,
Chris. 3 1441
Hi Chris,
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to add rows from one DataGrid
to the other. If there is any misunderstanding, please feel free to let me
know.
Generally, when we need to add rows from one DataGrid to the other, we have
to add rows in the source DataSet. Here is an example. when you click a row
on one DataGrid, that row will be added to the other DataGrid.
private void Form1_Load(object sender, System.EventArgs e)
{
SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM Employees",
this.sqlConnection1);
this.ds1 = new DataSet();
this.ds2 = new DataSet();
sda.FillSchema(ds1, SchemaType.Source);
sda.FillSchema(ds2, SchemaType.Source);
sda.Fill(ds1);
this.dataGrid1.DataSource = ds1.Tables[0];
this.dataGrid2.DataSource = ds2.Tables[0];
cm = (CurrencyManager)this.BindingContext[this.ds1.Tables[0]];
cm.CurrentChanged +=new EventHandler(cm_CurrentChanged);
}
private void cm_CurrentChanged(object sender, EventArgs e)
{
this.ds2.Tables[0].Rows.Add(this.ds1.Tables[0].Rows[this.cm.Position].ItemAr
ray);
}
HTH. If anything is unclear, please feel free to reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
I should have mentioned that I am talking in the context of web data
grid.
The idea seems to be clear and I am trying to incorporate the same but
any sample code(asp.net/vb.net) could be appreciated!
Thanks,
Chris. v-****@online.microsoft.com (Kevin Yu [MSFT]) wrote in message news:<C4**************@cpmsftngxa10.phx.gbl>... Hi Chris,
First of all, I would like to confirm my understanding of your issue. From your description, I understand that you need to add rows from one DataGrid to the other. If there is any misunderstanding, please feel free to let me know.
Generally, when we need to add rows from one DataGrid to the other, we have to add rows in the source DataSet. Here is an example. when you click a row on one DataGrid, that row will be added to the other DataGrid.
private void Form1_Load(object sender, System.EventArgs e) { SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM Employees", this.sqlConnection1); this.ds1 = new DataSet(); this.ds2 = new DataSet(); sda.FillSchema(ds1, SchemaType.Source); sda.FillSchema(ds2, SchemaType.Source); sda.Fill(ds1); this.dataGrid1.DataSource = ds1.Tables[0]; this.dataGrid2.DataSource = ds2.Tables[0];
cm = (CurrencyManager)this.BindingContext[this.ds1.Tables[0]]; cm.CurrentChanged +=new EventHandler(cm_CurrentChanged); }
private void cm_CurrentChanged(object sender, EventArgs e) {
this.ds2.Tables[0].Rows.Add(this.ds1.Tables[0].Rows[this.cm.Position].ItemAr ray); }
HTH. If anything is unclear, please feel free to reply to the post.
Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights."
Hi Chris,
In an ASP.NET senario, we can use the same idea to add row values, except
handling the CurrentChanged event and using CurrencyManager. We can use a
button to fire the event and search for checked rows to add.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights." This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris Plowman |
last post by:
Hi all,
I was wondering if anyone can help me with a really annoying problem I have
been having. I made a derived datagrid class that will select the row when
a user clicks anywhere on a cell...
|
by: Jim Heavey |
last post by:
Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that...
|
by: Steve |
last post by:
I have a datagrid that is created at run time
DataGrid dgG = new DataGrid();
BoundColumn bcB;
dgG.CellPadding = 5;
dgG.CellSpacing = 0;
dgG.GridLines = GridLines.Both;
dgG.CssClass =...
|
by: Shawn |
last post by:
Hi.
I already have a datagrid where I'm using paging. I have a stored procedure
that fills a temp table with 200-500 rows and then sends back 10 records at
the time. When I go to page 2 the SP...
|
by: mark |
last post by:
I fear my initial post was misleading.
I have a Windows application.
I have a numerical array which is displayed in a datagrid by way of a
datatable and a dataview.
I want my user to be...
|
by: Dave |
last post by:
Are there any add-on products or samples available that can do the following
in an vb.net datagrid
I want to compare 2 rows in a datagrid - one row from one database and
another row for another...
|
by: Kevin Hodgson |
last post by:
I have a standard .NET Datagrid (Databound to a SQL Dataset), and I need to
select all rows of the datagrid when a button is clicked, to allow a user to
copy the data, and then paste it into Excel...
|
by: Rob |
last post by:
I am trying to copy some data from one datagrid to another. The first
datagrid containing data is called DocList. The blank Datagrid that I am
trying to copy some data to is called DataGrid1.
...
|
by: Bill Nguyen |
last post by:
I need to add a checkbox in front of all the rows in a datagrid so that
users can select/unselect them.
Any help is greatly appreciated!
Bill
|
by: Bill nguyen |
last post by:
I use DatagridTableStyle to display data from table
WF_Carrier_FreightChart. USers than can add/delete/edit rows in the
Datagrid.
Since the Datagrid's datasource "dCarrierFreight" is just a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |