Re: Simple Question - I Think:/

From: William Ryan eMVP (dotnetguru_at_comcast.nospam.net)
Date: 04/22/04


Date: Thu, 22 Apr 2004 09:59:41 -0400

MadCrasyNewbie:

Like Deepak mentioned, you can set the field as a bit and therefore make it
an either/or scenario. If you bind it to a grid, then it will automatically
come in as a CheckBox for instance. 0 and 1 map to True and false in text
so databinding it to that field will get you the result. Remember though
that binding to this field is going to give you a SelectedValue or True
and/or False not 0 or 1. Moreover, if you check the type, you'll get
System.Boolean. When I did this a while back, I set the ValueMember to the
Bit field and I expected the Display to be true or false but the Actual
value to be 0 or 1. That's not the case, it's true or false for both.

This will still update like you expect though, so it's not really a problem
although I thought it might be when I first discovered it.

The bottom line, Deepak provided a complete and correct answer. When I was
learning this, I often thought too hard about stuff worrying about things
that didn't matter. In fact it all makes perfect sense now but I figured
I'd mention it in case anyone else suffers from the same problem ;-)

However, for a combo box and true and false,
"MadCrazyNewbie" <test@nospam.com> wrote in message
news:aR6cnX86D9BF6RrdSa8jmA@karoo.co.uk...
> Hey Group,
>
> A Really Simple one, I have a feild in my Database which I would like a
YES
> or a NO on, how would i setup my ComboBox to allow this, and for it to
> update my DB?
>
> Many Thanks
> MCN
>
>



Relevant Pages

  • Binding a grid to various sources.
    ... need to display and edit data from various fields from two of them: ... I want to display in the grid like this: ... Col1 would bind to fld1, ... it to the grid, I get 2 records, rather than one record with 2 columns. ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • Re: stored procedure results
    ... Am I correct in this being your scenario? ... datagrid on it that is being filled from an existing dataset. ... Do you want them in the footer of the grid? ... >>results to a data grid you can bind it. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: stored procedure results
    ... Am I correct in this being your scenario? ... datagrid on it that is being filled from an existing dataset. ... Do you want them in the footer of the grid? ... >>results to a data grid you can bind it. ...
    (microsoft.public.dotnet.framework.adonet)
  • Datagrid issue, (losing state if bound after page_load event).
    ... I am using a datagrid to display a 2d matrix of users and security levels. ... The form also has a dropdown of available users to add to the grid. ... so that newly added users will be in the database before the bind occurs. ... Note, this issue DOES NOT occur without the use of template columns, if i ...
    (microsoft.public.dotnet.framework.aspnet)
  • Problem with binding in Page_PreRender
    ... I am using a datagrid to display a 2d matrix of users and security levels. ... The form also has a dropdown of available users to add to the grid. ... added users will be in the database before the bind occurs. ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)