473,324 Members | 2,356 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,324 software developers and data experts.

DataGridView in Windows Forms 2.0

Hi All,

I am developing a Windows Forms 2.0 application. I have some questions on the
DataGridView.

I have two Datagridviews on the form which I have populated from the the database tables customer_group, and group using the datasource wizard. The table group for the gridview contains columns GroupID int and Name varchar datatypes and the table customer_group contains customerID int, GroupID int, memberNumber int. I have a Cell_Click event on the first gridview and when I click on the button in the group gridview it should add the particular row into the second gridview which is customer_gridview. but it gives me the following error.

"Input string was not in a correct format"

Could you please give me some idea and some code examples. I really appreciate your help.


Here is the Cell_Clickevent


private void groupDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
//MessageBox.Show("Cell click");

if (e.ColumnIndex == 0)
{

this.customer_GroupTableAdapter.Insert(int.Parse (this.customerIDTextBox.Text),
int.Parse(this.groupDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()),
null);



}



Kisankoori
Dec 18 '07 #1
4 1629
Plater
7,872 Expert 4TB
One of these does not contain valid integer data:

this.customerIDTextBox.Text
this.groupDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString()
Dec 18 '07 #2
Thanks for your quick reply Plater.

They all contain int data but for some reason I get this error. I think I should delete the data sources and create them again. May be in this way I can get it working. Actaully it worked for me before but I don't know why I got this error later.
It added the data in the second DataGridView but I had another problem, the second DataGridView couldn't get updated or Refreshed. I used the update and Refresh methods.

If it worked then how should I update the datagridview?

Thanks for your help. Looking forward to your reply.

Best

Kisankoori
Dec 18 '07 #3
Plater
7,872 Expert 4TB
If you set a breakpoint on that line, and examine those two fields, are either of them empty strings?
Dec 18 '07 #4
Plater, thanks for your reply, I will look into that.

Kisankoori
Dec 18 '07 #5

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

Similar topics

0
by: DraguVaso | last post by:
Hi, I'm using the DataGridView in VB.NET 2.0. The DataSource is a Generic List of a custom class0: lstMyPersonnes = New List(Of clsPersonne). When I add a new clsPersonne to lstMyPersonnes,...
0
by: wackyphill | last post by:
Anyone seen this? Know if its a bug? I'm pretty sure it is. I have a DataGridView control in a tab control who's datasource is a table in a dataset. In certain situations when I add a row to the...
6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
0
by: stevenhaochen | last post by:
I add a user control (a simple textbox control) to customize datagridview column to test how to add user control to datagridview. I found a weired behavior. I can not input "q", "!", "#". But I...
3
by: Daniel Manes | last post by:
I need a strategy to debug this situation... I can't put all the code involved, but here are some of the critical lines with comments: ------------------------- Private _parentDataCell As...
0
by: frostbb | last post by:
Ok, stumped one more time, I'm trying to learn how to use a DataGridView in place of the old DataGrid control. QUESTION: How do I map the columns returned from a RunTime sql query to the columns...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
18
by: Andrus | last post by:
Marc, Thank you very much. I have issue on implementing add row properly using this. User presses down arrow in last row in grid starting adding new row. Then user changes its mind desiding...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
4
by: alex21 | last post by:
Ok im getting this exception from a DataGridView control in my program. System.ArgumentOutOfRangeException was unhandled Message="Value of '132' is not valid for 'Value'. 'Value' should be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.