Conversion from type 'DBNull' to type 'Boolean' is not valid-SQL to ASP

I'm getting this error:
Conversion from type 'DBNull' to type 'Boolean' is not valid.

Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'Boolean' is not valid.

As you can see, the fields that I'm trying to access are null, and I don't know how to handle null values in these fields.  How do I deal with this?
<div id="page" style="text-align: left">
            <p style="text-align: left" id="P1" runat="server">
                </p>
            <p>
                <table style="width: 100%; height: 100%">
                    <tr>
                        <td style="width: 100px; height: 288px;">
                            <span><strong><asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False"
                                DataSourceID="Client_Name" Height="26px"
                                Width="353px" BorderColor="Transparent" BorderStyle="None" CellPadding="0" >
                                <Fields>
                                    <asp:BoundField DataField="Patient Name" ReadOnly="True" 
                                        SortExpression="Patient Name" HeaderText="Patient Name"/>
                                </Fields>
                            </asp:DetailsView>

                            </strong>
                            </span><span><span><asp:DetailsView ID="DetailsView1" runat="server"
                                AutoGenerateRows="False" DataSourceID="qry_Enrollment" Height="50px" Width="568px" DefaultMode="Edit">
                                <Fields>
												<asp:boundfield DataField="Patient_Id" HeaderText="Patient_Id" SortExpression="Patient_Id">
																<ControlStyle BorderStyle="None" Width="0px" />
												</asp:boundfield>
												<asp:boundfield DataField="DetailID" HeaderText="DetailID" SortExpression="DetailID">
																<ControlStyle BorderStyle="None" Width="0px" />
												</asp:boundfield>
												
												<asp:templatefield HeaderText="Package Billed" 
                                                    SortExpression="Prenatal_Package_Billed">
																<EditItemTemplate>
                                                                     <asp:CheckBox ID="CheckBox100" runat="server" Checked='<%# Bind("Prenatal_Package_Billed") %>' />
    															</EditItemTemplate>
													</asp:templatefield>
													
													
												<asp:templatefield HeaderText="Delivery Billed" 
                                                    SortExpression="Prenatal_Delivery_Billed">
																<EditItemTemplate>
                                                                    <asp:CheckBox ID="CheckBox101" runat="server" Checked='<%# Bind("Prenatal_Delivery_Billed") %>' />
																</EditItemTemplate>
													</asp:templatefield>													
													
																								
												<asp:templatefield ShowHeader="False">
																<EditItemTemplate>
																				<asp:Button ID="Button1" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />&nbsp;
																</EditItemTemplate>
																<ItemTemplate>
																				<asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
																</ItemTemplate>
												</asp:templatefield>
								</Fields>
                            </asp:DetailsView>

                                </span></span><asp:SqlDataSource id="qry_Enrollment" runat="server" ConnectionString="<%$ ConnectionStrings:MIHP_MaternalConnectionString %>" SelectCommand="SELECT Patient_Id, DetailID, Prenatal_Package_Billed, Prenatal_Delivery_Billed FROM Detail WHERE (Patient_Id = @Patient_Id) AND (DetailID = @DetailID)" UpdateCommand='UPDATE Detail SET Prenatal_Package_Billed = @Prenatal_Package_Billed,&#13;&#10;Prenatal_Delivery_Billed = @Prenatal_Delivery_Billed WHERE (Patient_ID = @Patient_Id) and (DetailID = @DetailID)'>


<SelectParameters>
                                   <asp:QueryStringParameter Name="Patient_Id" QueryStringField="Patient_Id" />
    <asp:QueryStringParameter Name="DetailID" QueryStringField="DetailId" />
                               </SelectParameters>
                                 <UpdateParameters>
                                     <asp:Parameter Name="Prenatal_Package_Billed" />
                                     <asp:Parameter Name="Prenatal_Delivery_Billed" />
                                    <asp:ControlParameter Name="Patient_ID" ControlID="DetailsView1" PropertyName="SelectedValue" />
                                     <asp:Parameter Name="DetailID" />
                                  </UpdateParameters>
                           </asp:SqlDataSource>

                            <asp:SqlDataSource ID="Client_Name" runat="server" ConnectionString="<%$ ConnectionStrings:MIHP_MaternalConnectionString %>"
                                SelectCommand="SELECT (Upper(Patient_Last_Name)+', '+ Upper(Patient_First_Name)) as [Patient Name]&#13;&#10;&#13;&#10;FROM VADER.Chorus_Reporting.dbo.Patient_Personal AS Patient_Personal_1 &#13;&#10;WHERE (Patient_Id = @Patient_Id)">
                                <SelectParameters>
                                    <asp:QueryStringParameter Name="Patient_Id" QueryStringField="Patient_Id" />
                                </SelectParameters>
                            </asp:SqlDataSource>

Open in new window

IntercareSupportAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

meetingexpectationsCommented:
Change your Select command as follows:

SelectCommand="SELECT Patient_Id, DetailID, Prenatal_Package_Billed, Case Prenatal_Delivery_Billed When 1 Then 1 Else 0 as Prenatal_Delivery_Billed FROM Detail WHERE (Patient_Id = @Patient_Id) AND (DetailID = @DetailID)"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IntercareSupportAuthor Commented:
Thanks!  That was a much simpler solution.  I did have to make a few adjustments.  Here they are...

SELECT Patient_Id, DetailID, CASE Prenatal_Package_Billed WHEN 1 THEN 1 ELSE 0 END AS Prenatal_Package_Billed, CASE Prenatal_Delivery_Billed WHEN 1 THEN 1 ELSE 0 END AS Prenatal_Delivery_Billed FROM Detail WHERE (Patient_Id = @Patient_Id) AND (DetailID = @DetailID)

Thanks again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.