Help Copying single row to same table

by Soli · 2 posts
5 years ago in .Net (C#, VB, etc)
Posted 5 years ago · Author
Hi guys. I'm trying to copy a single row as a new entry in the same table and make changes to a few cells, including a new Key. Can someone please help.

foreach (DataGridViewColumn Column in dataGridView1.Columns)
                    DataTable dtable = new WorkOrdersDataTable();

                    //dtable.Columns.Add(new DataColumn("Column 1"));
                    //dtable.Columns.Add(new DataColumn("Column 2"));

                    DataRow dr = dtable.NewRow();
                    DataGridViewRow dgvR = (DataGridViewRow)dataGridView1.CurrentRow.Clone();
                    if (dr!=null)                     

                        dataGridView1.DataSource = dtable;
                        DataTable dataTable = (DataTable)dataGridView1.DataSource;
                        DataRow drToAdd = dataTable.Rows.Add();
                        drToAdd["Status"] = "New";
                        drToAdd["ReportedBy"] = "System: Recurring";
                        drToAdd["ReportDate"] = dtRecurrent;
                        drToAdd["WorkOrderNumber"] = Guid.NewGuid();
                        dataGridView1.DataSource = workOrdersBindingSource;                       


System.ArgumentExceptionHResult=0x80070057Message=Unable to cast object of type 'System.Guid' to type 'System.IConvertible'.Couldn't store <ec184bf8-ee98-40e2-b18c-644132d7bf25> in WorkOrderNumber Column.  Expected type is Int32.Source=System.DataStackTrace:at System.Data.DataColumn.set_Item(Int32 record, Object value)at System.Data.DataRow.set_Item(DataColumn column, Object value)at System.Data.DataRow.set_Item(String columnName, Object value)at SerenityMaintenanceManagementSoftware.Form1.form1_Load(Object sender, EventArgs e) in C:.....
Posted 4 years ago
It looks dope to me.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here


Create an account

Sign up for a new account in our community. It's easy!

Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts