Re: Databinding and setting control value in code not working?
From: Sijin Joseph (sijinNOSPAMdotnet_at_hotmail.com)
Date: 09/05/04
- Next message: SLI: "Re: How to write SQL Command for insert data from TextBox"
- Previous message: dtaylor_at_harvard.edu: "Teen Girl Anal Movies"
- In reply to: Mark Essex: "Re: Databinding and setting control value in code not working?"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 05 Sep 2004 09:38:58 +0530
Hi Mark,
What i meant was that suppose in the UI i am going to show a boolean,
now i will have to decide wether DBNull values will be shown as false or
true in the UI since there is no other choice. Now suppose i decide to
show DBNull as false, then in the DataTable itself i set the value of
the column to false instead of DBNull, ofcourse in this case you lose
the ability to distinguish between columns that have been actually set
by the user.
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
Mark Essex wrote:
> 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
>>>
>>>
>
>
>
- Next message: SLI: "Re: How to write SQL Command for insert data from TextBox"
- Previous message: dtaylor_at_harvard.edu: "Teen Girl Anal Movies"
- In reply to: Mark Essex: "Re: Databinding and setting control value in code not working?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|