473,395 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

entering things in datagrid and updating DB content

6
hello everyone. i'm new here at this site so sorry if i may sound like a newb (i really am)

i'm using C# by the way.

i have a datagrid in my windows form and that datagrid's datasource is bound to a specific database using a MySQLConnection.

my problem now is that i want a user to actually enter some data into the datagrid and the data entered by the user should be reflected in the database(or the database should be updated with the new contents of the datagrid).

next i also would like to let the user copy and entire row of a data grid and that copied row would be pasted at the end of the data grid. i am currently using this code:

Expand|Select|Wrap|Line Numbers
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             //DataRowView cdr = dataGridView1.Rows.
  4.             int a = itemGrid.CurrentCell.RowIndex;
  5.             //MessageBox.Show(a.ToString()); //good
  6.  
  7.             //dataGridView1.Rows.Add();
  8.             int lastRow = itemGrid.NewRowIndex; //Rows.Count - 1;
  9.             //MessageBox.Show(numRows.ToString());
  10.             //itemGrid.Rows.Add();
  11.             CopyRows(itemGrid, a, lastRow);
  12.         }
  13.  
  14.         private void CopyRows(DataGridView DGVGrid, int SourceRowID, int DestinationRowID)
  15.         {
  16.             for (int j = 0; j < DGVGrid.Rows[SourceRowID].Cells.Count; j++)
  17.             {
  18.                 DGVGrid.Rows[DestinationRowID].Cells[j].Value = DGVGrid.Rows[SourceRowID].Cells[j].Value;
  19.             }
  20.         }
  21.  
however it does not really work like the way i planned it to. i hope someone could help me. thanks :)
May 31 '07 #1
3 1241
lemuel
6
anybody here who could give me an idea or even the logic on how to do what i asked? im really stuck with my project right now. :(
Jun 1 '07 #2
kenobewan
4,871 Expert 4TB
What part of the updating is not working as you want?
Jun 1 '07 #3
lemuel
6
when i enter things my datagrid will it automatically update my DB or not? if not, how would i update my DB with the changes made in the datagrid like addition of new members and editing of existing members.
Jun 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to...
2
by: Stephan Steiner | last post by:
Hi I'm using several DataTables in my program which are updated periodically. At the same I have those tables bound to DataGrids in my GUI. So far I've been doing all the processing in the same...
1
by: Soul | last post by:
Hi, I have a DataGrid which works. But if I load a new table to the DataGrid, it will still show those old data I load earlier. private void loadTableA() { if ( openFileDialog.ShowDialog()...
5
by: Bryan Masephol | last post by:
Hi All I got a datagrid and a ComboBox on a form. I populate the combobox with years for all the data avaiable. When the user chooses a year the datagrid is populated with the specific years...
0
by: Just D | last post by:
Hi All, Does anybody know how to write the following code? I have a database table with a few columns including: ID , "Task" , ForceRun . I need to show the DataGrid on the ASPX page with...
4
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
9
by: A P | last post by:
Hi! I have created a sample datagrid that can update data on a database. Please help me solve the problem, I have attached both aspx and code behind (aspx.vb): ______________________ ...
2
by: AA | last post by:
Do anyone know how to refresh the datagrid without setting datasource to nothing and initialize the grid again? My case is that I have form consisting from two part. The upper part is a datagrid...
14
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.