Re: Databinding and setting control value in code not working?

From: Mark Essex (messex_at_nospam.netalytics.com)
Date: 09/04/04


Date: Sat, 4 Sep 2004 09:17:22 -0400

Regarding your #2 option, for a NEW row, you don't have values set yet.
Also, for this particular scenario, we are not retrieving the schema, so I
don't think the Default Value is being enforced. Not really sure. When you
say you set the value in the DB to be whatever you are going to show, do you
mean you set the 'DefaultValue' in the database to '0' for example?

Mark

"Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
news:%2381XFtkkEHA.3432@TK2MSFTNGP14.phx.gbl...
> I have used two workarounds depending on the situation.
>
> 1. Manually commit the selection in the UI control, either by calling
> OnValidating method of the base class or by moving focus away from the
> control via code(eek!!)
>
> 2. I set the value in the DB to be whatever i am going to show in the
> UI, so in your case instead of setting the value to DBNull i would set
> it to false, which is the UI default.
>
> Sijin Joseph
> http://www.indiangeek.net
> http://weblogs.asp.net/sjoseph
>
>
>
> Mark Essex wrote:
> > Is there an event that must fire if you set the value of an control in
code?
> > For example, I have a combobox that is bound to a dataset. If I
> > check/uncheck the combobox, everything is fine during the save.
However,
> > when I create a new Row in the dataset, the default value for the
checkbox
> > is DBNull. I have the 'Format' event set up to check for this
situation,
> > and if it is DBNull, set the value = false. I know this is working,
because
> > when I change this to set the value = true, the checkbox defaults to
> > checked. HOwever, the underlying datacolumn value is still DB Null. If
I
> > don't explicitly do something to that control (check it for example),
then
> > when I save, I get an exception saying 'xx value can't be null', or
> > something along those lines. I have seen this same behavior with
Textboxes.
> > If I tab intot the textbox and back out, it would fine, otherwise, the
value
> > I set in Code didn't appear to 'notify' the dataset of the change.
> >
> > Just wondering if anybody else has seen this behavior and if so, how did
> > they get around it.
> >
> > Thanks,
> >
> > Mark
> >
> >



Relevant Pages

  • Re: New "base document" available
    ... be done about retrieving command line parameters. ... My suggestion was to use the MCS (Message Control System) which was for passing messages, control, and data between the system, run units, and others. ... "Objects" if you like...The point of using them is that the "function" can do vast amounts of work using new forms of Query Expression which are "SQL-like" but far removed from SQL in form and implementation. ...
    (comp.lang.cobol)
  • Re: New "base document" available
    ... be done about retrieving command line parameters. ... System) which was for passing messages, control, and data between the ... new forms of Query Expression which are "SQL-like" but far removed from SQL ...
    (comp.lang.cobol)
  • Re: Holy smokes! Failed forestprep???!?!?!
    ... my guess is that this isn't related to the forestprep itself. ... Mark Renoden ... >>> a member of the schema admins group and that all the DCs ... >>> Adprep was unable to upgrade the schema on the schema ...
    (microsoft.public.win2000.active_directory)
  • Re: Mini Stereo Problem
    ... Mark D. Zacharias wrote: ... The control is pretty well ... (It seems to me the control on yours is basically working, ... days--replace, don't repair. ...
    (sci.electronics.repair)
  • Re: Holy smokes! Failed forestprep???!?!?!
    ... Mark Renoden ... > a member of the schema admins group and that all the DCs ... > Adprep was unable to upgrade the schema on the schema ... Anyone ever seen a failed forestprep? ...
    (microsoft.public.win2000.active_directory)