-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: DotNetRanji
Message 2 in Discussion

Hi Suresh,

   I went thru your issue. 
 
   Your approach to remove the constraint and then adding the constraint after 
the swapping.  This is not an advaisable approach because when the user chages 
Bill to Mill the program does not know if he is going to swap the data btwn two 
rows  or is it an error entry. So you can not easily determine when you want to 
enable the constraint back.

   And also using BeginEdit and EndEdit of DataRow also will not help bcoz when 
a table is boud to grid  BeginEdit is automatically called when you edit a data 
in the grid and it automatically calls the EndEdit() when you navigate to the 
next row in the grid. So as soon as the EndEdit() is called it will check all 
the constraints and you modificaion will fail.

Thanks and Regards,
Ranjith
   


-----Original Message-----
From: Suresh Kumar R [mailto:[EMAIL PROTECTED]
Sent: Fri 4/28/2006 3:30 AM
To: BDOTNET
Subject: Winforms Datagrid Vs DataRow BeginEdit
 
-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Suresh Kumar R
Message 1 in Discussion

Hi Folks, 

Scenario:- 
I have a DataTable (T1) with 2 columns "id" and "name", i have bound this to a  
winforms datagrid (D1). The table T1 is added with a uniqueconstraint as here. 
T1.Constraints.Add(new UniqueConstraint("say the Name column"));
// So this says that, the name column, can't have duplication of value. 
Assume that the T1 is having 2 rows with values like this
row 1 - "1", "Bill"
row 2 - "2", "Mill" 
When i run this application, the grid is displayed. i can edit the value in the 
datagrid. If  I am editing the value of second row to "Bill" from "Mill", it is 
clear that, this violates uniqueconstraint. Assume I want to edit this in a way 
as follows, ie, first row I want to make as "Mill" and second row I want as 
"Bill". For doing this, first I have to modify one row and go to the next row 
to edit that. But the uniqueconstraint doesn't allow this swapping. One 
solution I can think is, I can drop the constraint till I edit and then once I 
swap the value, I can invoke the constraint back into place. But I want to make 
use of the DataRow.BeginEdit method to do this (Correct me if this BeginEdit is 
not meant for it). 
Question:- 
In MSDN, in this link for DataRow.BeginEdit,  
http://msdn2.microsoft.com/en-us/library/system.data.datarow.beginedit.aspx 
In this, they have given an example, it says that though the uniqueconstraint 
is there for a table, I can invoke the beginedit and do the task and invoke the 
endedit after finishing. Through this I can easily swap the values. 
In this link, it is mentioned as "The BeginEdit method is called implicitly 
when the user changes the value of a data-bound control". Here the datagrid is 
databound to a table called T1 in our case. So when I edit the row it should 
trigger the BeginEdit and it should allow me to swap values "Bill" to "Mill" 
and "Mill" to "Bill". 
1) "DataRow.BeginEdit", can it be used in this manner? or Am I trying something 
wrong? 
Thanks in Advance, 
Suki

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]




-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to