Gridview check linqDataSource before binding

I have been trying to find a solution for a while regarding the gridviews.

I am using Linq to Sql, but can use something else for the grids.

What I need to do, is check my datasource to see if there are any records, if there are, bind my grid and add a row.
If the datasource is empty then I need to create a fake row so that the header will show.

I have tried multiple ways to implement this, including trying the listview, with no luck.

I have attached my latest attempt, hoping that someone can help me so I can move on with this project.

Thaniks
In this example I am using sqldatasource, but I would prefer to use linq to sql.

 <tr>
          <td align="right" colspan="2">
          
              <asp:GridView ID="grdDefaults" runat="server" AllowSorting="True" 
                  AutoGenerateColumns="False" AutoGenerateDeleteButton="True" 
                  AutoGenerateEditButton="True" BorderColor="LightGray" Font-Size="8pt" 
                  ShowFooter="True" Width="100%" DataSourceID="sqldsWorkDays">
                  <AlternatingRowStyle BackColor="#FFFFCC" />
                  <Columns>
                      <asp:TemplateField ShowHeader="False">
                          <ItemTemplate>
                              <asp:Label ID="DefaultWorkDaysID" runat="server" 
                                  Text='<%# Bind("DefaultWorkDaysID") %>' Visible="False" />
                          </ItemTemplate>
                      </asp:TemplateField>
                      <asp:TemplateField ShowHeader="False">
                          <ItemTemplate>
                              <asp:Label ID="DefaultID" runat="server" Text='<%# Bind("DefaultID") %>' 
                                  Visible="False" />
                          </ItemTemplate>
                      </asp:TemplateField>
                      <asp:TemplateField HeaderText="Day of Week">
                          <ItemTemplate>
                              <asp:DropDownList ID="DDDOW" runat="server" 
                                  DataTextField='<%# Bind("WorkDay") %>' DataValueField='<%# Bind("WorkDay") %>'>
                                  <asp:ListItem>Select...</asp:ListItem>
                                  <asp:ListItem>Sunday</asp:ListItem>
                                  <asp:ListItem>Monday</asp:ListItem>
                                  <asp:ListItem>Tuesday</asp:ListItem>
                                  <asp:ListItem>Wednesday</asp:ListItem>
                                  <asp:ListItem>Thursday</asp:ListItem>
                                  <asp:ListItem>Friday</asp:ListItem>
                                  <asp:ListItem>Saturday</asp:ListItem>
                              </asp:DropDownList>
                              <asp:ListSearchExtender ID="ListSearchExtender1" runat="server" 
                                  TargetControlID="DDDOW">
                              </asp:ListSearchExtender>
                          </ItemTemplate>
                          <ControlStyle BorderStyle="None" Width="100%" />
                      </asp:TemplateField>
                      <asp:TemplateField HeaderText="Start Time">
                          <ItemTemplate>
                              <asp:TextBox ID="txtStartTime" runat="server" Text='<%# Bind("StartTime") %>'></asp:TextBox>
                              <asp:MaskedEditExtender ID="MaskedEditExtender1" runat="server" 
                                  AcceptAMPM="true" Mask="99:99" MaskType="Time" TargetControlID="txtStartTime">
                              </asp:MaskedEditExtender>
                          </ItemTemplate>
                          <ControlStyle BorderStyle="None" Width="100%" />
                          <HeaderStyle Width="24%" />
                      </asp:TemplateField>
                      <asp:TemplateField HeaderText="End Time">
                          <FooterTemplate>
                              <asp:LinkButton ID="lnkDefaultNewRow" runat="server" Font-Bold="False" 
                                  Font-Size="9pt" OnClick="lnkAddNewRow_Click" >Add New Row</asp:LinkButton>
                          </FooterTemplate>
                          <ItemTemplate>
                              <asp:TextBox ID="txtEndTime" runat="server" Text='<%# Bind("EndTime") %>'></asp:TextBox>
                              <asp:MaskedEditExtender ID="MaskedEditExtender2" runat="server" 
                                  AcceptAMPM="true" Mask="99:99" MaskType="Time" TargetControlID="txtEndTime">
                              </asp:MaskedEditExtender>
                          </ItemTemplate>
                          <ControlStyle BorderStyle="None" Width="100%" />
                          <HeaderStyle Width="24%" />
                      </asp:TemplateField>
                  </Columns>
                  <HeaderStyle BackColor="DarkBlue" Font-Size="9pt" ForeColor="White" />
              </asp:GridView>
               
              
                                          
              <asp:SqlDataSource ID="sqldsWorkDays" runat="server" OnDataBinding="AddRowIfNecessary" 
                  ConnectionString="<%$ ConnectionStrings:SalonConnectionString %>" 
                  DeleteCommand="DELETE FROM [DefaultWorkDays] WHERE [DefaultWorkDaysID] = @DefaultWorkDaysID" 
                  InsertCommand="INSERT INTO [DefaultWorkDays] ([DefaultID], [WorkDay], [StartTime], [EndTime]) VALUES (@DefaultID, @WorkDay, @StartTime, @EndTime)" 
                  SelectCommand="SELECT * FROM [DefaultWorkDays] WHERE ([DefaultID] = @DefaultID)" 
                  UpdateCommand="UPDATE [DefaultWorkDays] SET [DefaultID] = @DefaultID, [WorkDay] = @WorkDay, [StartTime] = @StartTime, [EndTime] = @EndTime WHERE [DefaultWorkDaysID] = @DefaultWorkDaysID">
                  <DeleteParameters>
                      <asp:Parameter Name="DefaultWorkDaysID" Type="Int32" />
                  </DeleteParameters>
                  <InsertParameters>
                      <asp:Parameter Name="DefaultID" Type="Int32" />
                      <asp:Parameter Name="WorkDay" Type="String" />
                      <asp:Parameter Name="StartTime" Type="Int32" />
                      <asp:Parameter Name="EndTime" Type="Int32" />
                  </InsertParameters>
                  <SelectParameters>
                      <asp:ControlParameter ControlID="txtDefaultID" Name="DefaultID" 
                          PropertyName="Text" Type="Int32" />
                  </SelectParameters>
                  <UpdateParameters>
                      <asp:Parameter Name="DefaultID" Type="Int32" />
                      <asp:Parameter Name="WorkDay" Type="String" />
                      <asp:Parameter Name="StartTime" Type="Int32" />
                      <asp:Parameter Name="EndTime" Type="Int32" />
                      <asp:Parameter Name="DefaultWorkDaysID" Type="Int32" />
                  </UpdateParameters>
              </asp:SqlDataSource>
               
              
                                          
        </td>
</tr>

Open in new window

SheritlwAsked:
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.

Muhammad ZamanSoftware Development LeadCommented:

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
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.