By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

AddNew of the BindingContext isn't working..... ?

P: n/a
I have a form, oddly enough the same one with the expression column that
is giving me a headache, and on this form I have a dataset that has a
couple of tables in it that are related. If I do a AddNew on the Binding
Context for the parent, it doesn't seem to work. If I click the new
(just does an addnew, and thats it) the fields do not clear out, and if
I click new again, it just says that the first field that doesn't allow
nulls, doesn't allow nulls. I can't seem to figure it out... I don't
know if it's related, but also another problem I am having is if I
change the position property, even though none of the data has changed,
it will set the modified flag of the dataset. None of my other forms
does this, so I know it's not default behavior.... I am lost.. Any idea
where to even start to look?

Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Aaron,

I think you need to give us some code to explain it more, now we even don't
know if you use the currencymanager.addnew or the dataview.addnet. I think
there are more things what could be in thousand ways done in your question.

Cor

"Aaron Smith" <th**********@smithcentral.net>
I have a form, oddly enough the same one with the expression column that is
giving me a headache, and on this form I have a dataset that has a couple
of tables in it that are related. If I do a AddNew on the Binding Context
for the parent, it doesn't seem to work. If I click the new (just does an
addnew, and thats it) the fields do not clear out, and if I click new
again, it just says that the first field that doesn't allow nulls, doesn't
allow nulls. I can't seem to figure it out... I don't know if it's related,
but also another problem I am having is if I change the position property,
even though none of the data has changed, it will set the modified flag of
the dataset. None of my other forms does this, so I know it's not default
behavior.... I am lost.. Any idea where to even start to look?

Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #2

P: n/a
I dont' know how much to post, but this is my New button in the toolbar:

Private Sub cmdNew_Click(ByVal sender As System.Object, ByVal e As
C1.Win.C1Command.ClickEventArgs) Handles cmdNew.Click
Try
Me.BindingContext(CoursesDS1, "Courses").EndCurrentEdit()
Me.BindingContext(CoursesDS1, "Courses").AddNew()
Catch ex As Exception
Misc.ShowError(ex.Message())
End Try
End Sub

This is a pretty standard form.. Nothing fancy, MSDE. Quite a few
tables, but only two tables that get changed from here. The rest are
"lookups" ... There is a course table that has a related child called
InstClasses ...

Is this enough? What specific code do you need? All I did was drag some
data adapters on the form, run their wizards, and then created the
datasets using those wizards. Thats it.

Aaron

Cor Ligthert wrote:
Aaron,

I think you need to give us some code to explain it more, now we even don't
know if you use the currencymanager.addnew or the dataview.addnet. I think
there are more things what could be in thousand ways done in your question.

Cor

"Aaron Smith" <th**********@smithcentral.net>
I have a form, oddly enough the same one with the expression column that is
giving me a headache, and on this form I have a dataset that has a couple
of tables in it that are related. If I do a AddNew on the Binding Context
for the parent, it doesn't seem to work. If I click the new (just does an
addnew, and thats it) the fields do not clear out, and if I click new
again, it just says that the first field that doesn't allow nulls, doesn't
allow nulls. I can't seem to figure it out... I don't know if it's related,
but also another problem I am having is if I change the position property,
even though none of the data has changed, it will set the modified flag of
the dataset. None of my other forms does this, so I know it's not default
behavior.... I am lost.. Any idea where to even start to look?

Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #3

P: n/a
Ok.. I found the location of the problem. This doesn't mean I found the
solution.. lol

I have two custom textboxes on the form that are derived from Textbox..
I just did this so that I could have the data formatted to Currency. If
this procedure is in there to add the formatting, then the AddNew does
not work.

If I take it out, everything works great. I would rather not set the
formatting in the form every time I need to use the currency mask. I
want, well lets just say I need, it inside the custom textbox class. If
it's not in the textbox, then all sorts of problems will happen when we
start having the other developers work on these projects.

Private Sub CurrencyMaskedTextBox_BindingContextChanged(ByVal
sender As Object, ByVal e As System.EventArgs) Handles
MyBase.BindingContextChanged
If Me.DataBindings.Count > 0 Then
AddHandler Me.DataBindings(0).Format, AddressOf
DecimalToCurrencyString
AddHandler Me.DataBindings(0).Parse, AddressOf
CurrencyStringToDecimal
End If
End Sub

What should I be doing instead of this to make it work right?

Aaron

Aaron Smith wrote:
I dont' know how much to post, but this is my New button in the toolbar:

Private Sub cmdNew_Click(ByVal sender As System.Object, ByVal e As
C1.Win.C1Command.ClickEventArgs) Handles cmdNew.Click
Try
Me.BindingContext(CoursesDS1, "Courses").EndCurrentEdit()
Me.BindingContext(CoursesDS1, "Courses").AddNew()
Catch ex As Exception
Misc.ShowError(ex.Message())
End Try
End Sub

This is a pretty standard form.. Nothing fancy, MSDE. Quite a few
tables, but only two tables that get changed from here. The rest are
"lookups" ... There is a course table that has a related child called
InstClasses ...

Is this enough? What specific code do you need? All I did was drag some
data adapters on the form, run their wizards, and then created the
datasets using those wizards. Thats it.

Aaron

Cor Ligthert wrote:
Aaron,

I think you need to give us some code to explain it more, now we even
don't know if you use the currencymanager.addnew or the
dataview.addnet. I think there are more things what could be in
thousand ways done in your question.

Cor

"Aaron Smith" <th**********@smithcentral.net>
I have a form, oddly enough the same one with the expression column
that is giving me a headache, and on this form I have a dataset that
has a couple of tables in it that are related. If I do a AddNew on
the Binding Context for the parent, it doesn't seem to work. If I
click the new (just does an addnew, and thats it) the fields do not
clear out, and if I click new again, it just says that the first
field that doesn't allow nulls, doesn't allow nulls. I can't seem to
figure it out... I don't know if it's related, but also another
problem I am having is if I change the position property, even though
none of the data has changed, it will set the modified flag of the
dataset. None of my other forms does this, so I know it's not default
behavior.... I am lost.. Any idea where to even start to look?

Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.



--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #4

P: n/a
Problem solved.... The format event was the problem. In the event
handler, it was only checking the type. It seems that if the value
itself is DBNull, it was still continuing on. No exceptions were being
thrown..

Public Shared Sub DecimalToCurrencyString(ByVal sender As Object,
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then Exit Sub ' Added this line
to fix the problem.
If Not cevent.DesiredType Is GetType(String) Then Exit Sub
cevent.Value = Strings.Format(CDec(cevent.Value), "Currency")
End Sub
Aaron Smith wrote:
Ok.. I found the location of the problem. This doesn't mean I found the
solution.. lol

I have two custom textboxes on the form that are derived from Textbox..
I just did this so that I could have the data formatted to Currency. If
this procedure is in there to add the formatting, then the AddNew does
not work.

If I take it out, everything works great. I would rather not set the
formatting in the form every time I need to use the currency mask. I
want, well lets just say I need, it inside the custom textbox class. If
it's not in the textbox, then all sorts of problems will happen when we
start having the other developers work on these projects.

Private Sub CurrencyMaskedTextBox_BindingContextChanged(ByVal sender
As Object, ByVal e As System.EventArgs) Handles
MyBase.BindingContextChanged
If Me.DataBindings.Count > 0 Then
AddHandler Me.DataBindings(0).Format, AddressOf
DecimalToCurrencyString
AddHandler Me.DataBindings(0).Parse, AddressOf
CurrencyStringToDecimal
End If
End Sub

What should I be doing instead of this to make it work right?

Aaron

Aaron Smith wrote:
I dont' know how much to post, but this is my New button in the toolbar:

Private Sub cmdNew_Click(ByVal sender As System.Object, ByVal e As
C1.Win.C1Command.ClickEventArgs) Handles cmdNew.Click
Try
Me.BindingContext(CoursesDS1, "Courses").EndCurrentEdit()
Me.BindingContext(CoursesDS1, "Courses").AddNew()
Catch ex As Exception
Misc.ShowError(ex.Message())
End Try
End Sub

This is a pretty standard form.. Nothing fancy, MSDE. Quite a few
tables, but only two tables that get changed from here. The rest are
"lookups" ... There is a course table that has a related child called
InstClasses ...

Is this enough? What specific code do you need? All I did was drag
some data adapters on the form, run their wizards, and then created
the datasets using those wizards. Thats it.

Aaron

Cor Ligthert wrote:
Aaron,

I think you need to give us some code to explain it more, now we even
don't know if you use the currencymanager.addnew or the
dataview.addnet. I think there are more things what could be in
thousand ways done in your question.

Cor

"Aaron Smith" <th**********@smithcentral.net>

I have a form, oddly enough the same one with the expression column
that is giving me a headache, and on this form I have a dataset that
has a couple of tables in it that are related. If I do a AddNew on
the Binding Context for the parent, it doesn't seem to work. If I
click the new (just does an addnew, and thats it) the fields do not
clear out, and if I click new again, it just says that the first
field that doesn't allow nulls, doesn't allow nulls. I can't seem to
figure it out... I don't know if it's related, but also another
problem I am having is if I change the position property, even
though none of the data has changed, it will set the modified flag
of the dataset. None of my other forms does this, so I know it's not
default behavior.... I am lost.. Any idea where to even start to look?

Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.




--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #5

P: n/a
Aaron,

I am glad that you solved it without myhelp, however often is the need to
describe something for someone else the first step to find a solution for a
problem

Cor

"Aaron Smith" <th**********@smithcentral.net>
Problem solved.... The format event was the problem. In the event handler,
it was only checking the type. It seems that if the value itself is
DBNull, it was still continuing on. No exceptions were being thrown..

Public Shared Sub DecimalToCurrencyString(ByVal sender As Object,
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then Exit Sub ' Added this line to
fix the problem.
If Not cevent.DesiredType Is GetType(String) Then Exit Sub
cevent.Value = Strings.Format(CDec(cevent.Value), "Currency")
End Sub
Aaron Smith wrote:
Ok.. I found the location of the problem. This doesn't mean I found the
solution.. lol

I have two custom textboxes on the form that are derived from Textbox.. I
just did this so that I could have the data formatted to Currency. If
this procedure is in there to add the formatting, then the AddNew does
not work.

If I take it out, everything works great. I would rather not set the
formatting in the form every time I need to use the currency mask. I
want, well lets just say I need, it inside the custom textbox class. If
it's not in the textbox, then all sorts of problems will happen when we
start having the other developers work on these projects.

Private Sub CurrencyMaskedTextBox_BindingContextChanged(ByVal sender
As Object, ByVal e As System.EventArgs) Handles
MyBase.BindingContextChanged
If Me.DataBindings.Count > 0 Then
AddHandler Me.DataBindings(0).Format, AddressOf
DecimalToCurrencyString
AddHandler Me.DataBindings(0).Parse, AddressOf
CurrencyStringToDecimal
End If
End Sub

What should I be doing instead of this to make it work right?

Aaron

Aaron Smith wrote:
I dont' know how much to post, but this is my New button in the toolbar:

Private Sub cmdNew_Click(ByVal sender As System.Object, ByVal e As
C1.Win.C1Command.ClickEventArgs) Handles cmdNew.Click
Try
Me.BindingContext(CoursesDS1, "Courses").EndCurrentEdit()
Me.BindingContext(CoursesDS1, "Courses").AddNew()
Catch ex As Exception
Misc.ShowError(ex.Message())
End Try
End Sub

This is a pretty standard form.. Nothing fancy, MSDE. Quite a few
tables, but only two tables that get changed from here. The rest are
"lookups" ... There is a course table that has a related child called
InstClasses ...

Is this enough? What specific code do you need? All I did was drag some
data adapters on the form, run their wizards, and then created the
datasets using those wizards. Thats it.

Aaron

Cor Ligthert wrote:

Aaron,

I think you need to give us some code to explain it more, now we even
don't know if you use the currencymanager.addnew or the
dataview.addnet. I think there are more things what could be in
thousand ways done in your question.

Cor

"Aaron Smith" <th**********@smithcentral.net>

> I have a form, oddly enough the same one with the expression column
> that is giving me a headache, and on this form I have a dataset that
> has a couple of tables in it that are related. If I do a AddNew on the
> Binding Context for the parent, it doesn't seem to work. If I click
> the new (just does an addnew, and thats it) the fields do not clear
> out, and if I click new again, it just says that the first field that
> doesn't allow nulls, doesn't allow nulls. I can't seem to figure it
> out... I don't know if it's related, but also another problem I am
> having is if I change the position property, even though none of the
> data has changed, it will set the modified flag of the dataset. None
> of my other forms does this, so I know it's not default behavior.... I
> am lost.. Any idea where to even start to look?
>
> Aaron
> --
> ---
> Aaron Smith
> Remove -1- to E-Mail me. Spam Sucks.



--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #6

P: n/a
Yea, that was one that I don't think anyone could have helped me with
unless they saw all the code for the form. I didn't even know where to
look until I started to remove the bindings for all the textbox objects.
Unfortunately, out of about 30 on the form, that was the last one I removed.

Cor Ligthert wrote:
Aaron,

I am glad that you solved it without myhelp, however often is the need to
describe something for someone else the first step to find a solution for a
problem

Cor

"Aaron Smith" <th**********@smithcentral.net>
Problem solved.... The format event was the problem. In the event handler,
it was only checking the type. It seems that if the value itself is
DBNull, it was still continuing on. No exceptions were being thrown..

Public Shared Sub DecimalToCurrencyString(ByVal sender As Object,
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then Exit Sub ' Added this line to
fix the problem.
If Not cevent.DesiredType Is GetType(String) Then Exit Sub
cevent.Value = Strings.Format(CDec(cevent.Value), "Currency")
End Sub
Aaron Smith wrote:
Ok.. I found the location of the problem. This doesn't mean I found the
solution.. lol

I have two custom textboxes on the form that are derived from Textbox.. I
just did this so that I could have the data formatted to Currency. If
this procedure is in there to add the formatting, then the AddNew does
not work.

If I take it out, everything works great. I would rather not set the
formatting in the form every time I need to use the currency mask. I
want, well lets just say I need, it inside the custom textbox class. If
it's not in the textbox, then all sorts of problems will happen when we
start having the other developers work on these projects.

Private Sub CurrencyMaskedTextBox_BindingContextChanged(ByVal sender
As Object, ByVal e As System.EventArgs) Handles
MyBase.BindingContextChanged
If Me.DataBindings.Count > 0 Then
AddHandler Me.DataBindings(0).Format, AddressOf
DecimalToCurrencyString
AddHandler Me.DataBindings(0).Parse, AddressOf
CurrencyStringToDecimal
End If
End Sub

What should I be doing instead of this to make it work right?

Aaron

Aaron Smith wrote:
I dont' know how much to post, but this is my New button in the toolbar:

Private Sub cmdNew_Click(ByVal sender As System.Object, ByVal e As
C1.Win.C1Command.ClickEventArgs) Handles cmdNew.Click
Try
Me.BindingContext(CoursesDS1, "Courses").EndCurrentEdit()
Me.BindingContext(CoursesDS1, "Courses").AddNew()
Catch ex As Exception
Misc.ShowError(ex.Message())
End Try
End Sub

This is a pretty standard form.. Nothing fancy, MSDE. Quite a few
tables, but only two tables that get changed from here. The rest are
"lookups" ... There is a course table that has a related child called
InstClasses ...

Is this enough? What specific code do you need? All I did was drag some
data adapters on the form, run their wizards, and then created the
datasets using those wizards. Thats it.

Aaron

Cor Ligthert wrote:
>Aaron,
>
>I think you need to give us some code to explain it more, now we even
>don't know if you use the currencymanager.addnew or the
>dataview.addnet. I think there are more things what could be in
>thousand ways done in your question.
>
>Cor
>
>"Aaron Smith" <th**********@smithcentral.net>
>
>>I have a form, oddly enough the same one with the expression column
>>that is giving me a headache, and on this form I have a dataset that
>>has a couple of tables in it that are related. If I do a AddNew on the
>>Binding Context for the parent, it doesn't seem to work. If I click
>>the new (just does an addnew, and thats it) the fields do not clear
>>out, and if I click new again, it just says that the first field that
>>doesn't allow nulls, doesn't allow nulls. I can't seem to figure it
>>out... I don't know if it's related, but also another problem I am
>>having is if I change the position property, even though none of the
>>data has changed, it will set the modified flag of the dataset. None
>>of my other forms does this, so I know it's not default behavior.... I
>>am lost.. Any idea where to even start to look?
>>
>>Aaron
>>--
>>---
>>Aaron Smith
>>Remove -1- to E-Mail me. Spam Sucks.
>
>
>
>
>


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.