-----------------------------------------------------------
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]