473,771 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.InvalidO perationExcepti on will be thrown if I call the method DataGridView.Ro ws.Add, How to resolve?

I want to programmaticall y add a row to DataGridView (a datasource was
binded with it), but when I call the method DataGridView.Ro ws.Add, a
System.InvalidO perationExcepti on will be thrown and the error message is:
Rows cannot be programmaticall y added to the DataGridView's rows
collection when the control is data-bound.

But if I create a DataGridView without any datasource binded, the method
DataGridView.Ro ws.Add can work normally.
I don't know the reason why?


Oct 15 '06 #1
2 6182
Once bound, the UI is not the "master" of the data; instead, locate
your datasource, and ask *that* to add a record. This should (if the
appropriate interfaces are met) communicate back to the UI to say "a
change happened; update thyself".

How to do the add depends on your specific datasource.

Marc

Oct 15 '06 #2
Thank you very much!

I can add row now!
DataTable dt = (DataTable)(Bin dingSource)Data GrideView.DataS ource;
DataRow row = dt.NewRow();
row["name"] = "test";
dt.Rows.Add(row );

"Marc Gravell" <ma**********@g mail.com>
??????:11****** *************** *@e3g2000cwe.go oglegroups.com. ..
Once bound, the UI is not the "master" of the data; instead, locate
your datasource, and ask *that* to add a record. This should (if the
appropriate interfaces are met) communicate back to the UI to say "a
change happened; update thyself".

How to do the add depends on your specific datasource.

Marc

Oct 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
533
by: Erick | last post by:
Hi, I have a Installer class used to install my windows service, it was created by the wizard that is in the VS, I just whent into the properties and set up the properties of the ServiceInstaller member by using the properties windows. But I choose the DinamicProperties, the wizard created into the "InitializeComponents" two assignations of the ServiceInstaller properties by instanciating the System.Configuration.AppSettingsReader this...
10
14857
by: Mae Lim | last post by:
Dear all, I'm new to C# WebServices. I compile the WebService project it return no errors "Build: 1 succeeded, 0 failed, 0 skipped". Basically I have 2 WebMethod, when I try to invoke the first method it is working fine. Then when I try to invoke the second method it return me an error, Just In-Time Debugging, with error message "An exception 'System.StackOverflowException' has occurred in WebServices"
6
7224
by: Arthur Dent | last post by:
How do you sort a generic collection derived from System.Collections.ObjectModel.Collection? Thanks in advance, - Arthur Dent
0
2056
by: nicomp | last post by:
I created a Web Service: I imported System.Data.SqlClient so I could access SQL server tables programmatically. The web service builds and deploys with no problems. When I try to add the corresponding Web Reference to the Web Site project I get the error listed below. I am able to create other Web Services on the same server and I am able to add Web Referneces to them. I have narrowed it down to the "Imports System.Data.SqlClient"...
0
2321
by: schoultzy | last post by:
Hello Everyone, I have been trying to figure this one out for two days now. I have created a DataGridView which is populated by an ObjectDataSource. My problem occurs when I attempt to use the Edit feature of the DataGridView. I have set several of the BoundField elements of the DataGridView to ReadOnly="True". When I attempt to use the Edit feature to UPDATE the rows in the DataGridView I get a System.NullReferenceException for...
3
14225
by: Joseph Geretz | last post by:
System.InvalidOperationException: WebServiceBindingAttribute is required on proxy classes. My environment: Visual Studio 2005, targeting FX 2.0; I've developed a Web Service which uses DIME to transfer file attachments to and from the server. I'm using WSE 2.0 SP3 which is supposed to support FX 2.0, as far as I know. (We will soon move on to MTOM, however I'm stuck with DIME for now; the solution was originally written for FX 1.1, and I...
2
4088
by: koredump | last post by:
Hi all, I have a windows app that makes some asyc calls to my webservice (WSE 3.0 with MTOM). exception gets thrown in the client win app. This exception is being thrown on another thread by a class in the System.Web.Services namespace and I have not been able to catch it and dispose of it. I've tried placing try/catch blocks in several places in my code, but this exception doesn't seem to bubble up the stack.
0
2546
by: cl0306 | last post by:
I get the following invalidoperationexception: Operation did not succeed because the program cannot commit or quit a cell value change. raised when I try to add a UserControl to a Panel. The UserControl in question has already been initialized and contains a DataGridView which has already been bound to a datasource. To try to resolve I have tried making the cells readonly and have also set AllowUserToAddRows to false. Any ideas on...
11
3515
by: Ed Bitzer | last post by:
I have been able using the namespace System.Web.Mail and its method Smtp.mail.send to mail simple text messages to a small group within our 55 and older community. I need help expanding the programs capabilities. Searching this forum I did not find any related information so if I have chosen poorly, I would appreciate a suggestion of a more appropriate dotnet forum. Now what I wish is the ability to send bcc's rather than to: (would be...
0
9619
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10260
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.