Gridview datasoure for asp.net 4.5

I am trying to convert an older version of asp.net to asp.net 4.5 and I can't figure out the new way of assigning the datasource.

The old version is:
           <asp:GridView ID="gvClientSpkgList" runat="server" AllowPaging="True"
            AllowSorting="True" AutoGenerateColumns="False"
            OnPageIndexChanging="gvClientSpkgList_PageIndexChanging"
            OnSorting="gvClientSpkgList_Sorting" PagerSettings-Mode="NumericFirstLast"
            PageSize="30" Style="font-weight: 700">
            <PagerSettings Mode="NumericFirstLast" />
            <Columns>
                <%-----------------------Column - Show Attempts (only if Employee)--------------%>
                <asp:HyperLinkField DataNavigateUrlFields="ServicePkgID"
                    DataNavigateUrlFormatString="~/SecurePages/ClientSpkgAttempts.aspx?ServicePkgID={0}"
                    Text="Show Attempts" />
                <%-----------------------Column - Service Pkg ID--------------------------------%>
                <asp:BoundField DataField="ServicePkgID" HeaderText="ServicePkg"
                    InsertVisible="False" ReadOnly="True" SortExpression="ServicePkgID" />
                <%-----------------------Column - Status----------------------------------------%>
                <asp:TemplateField HeaderText="Status" SortExpression="ClientStatusID">
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server"
                            DataSourceID="SqlDataSourceClientStatus" DataTextField="ClientStatusText"
                            DataValueField="ClientStatusID" Enabled="False"
                            SelectedValue='<%# Bind("ClientStatusID") %>' Width="90px">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SqlDataSourceClientStatus" runat="server"
                            ConnectionString="<%$ ConnectionStrings:integrity_dbLocalConnectionString %>"
                            SelectCommand="GetClientStatuses" SelectCommandType="StoredProcedure">
                        </asp:SqlDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <%-----------------------Column - Assigned To (only in Admin view)---------------%>
                <asp:TemplateField HeaderText="Assigned To" SortExpression="Assignedto" Visible = "false">
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownListAssignTo" runat="server"
                            DataSourceID="SqlDataSourceAssignedto" DataTextField="empUserName"
                            DataValueField="empID" SelectedValue='<%# Bind("AssignedTo") %>' Width="90px">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SqlDataSourceAssignedto" runat="server"
                            ConnectionString="<%$ ConnectionStrings:integrity_dbLocalConnectionString %>"
                            SelectCommand="GetEmployeeNames" SelectCommandType="StoredProcedure">
                        </asp:SqlDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <%-----------------------Column - DateIn-----------------------------------------%>
                <asp:BoundField DataField="DateIn" DataFormatString="{0:M/dd/yyyy}"
                    HeaderText="Date In" HtmlEncode="False" SortExpression="DateIn" />
                <%-----------------------Column - Date Closed------------------------------------%>
                <asp:BoundField DataField="DateClosed" DataFormatString="{0:M/dd/yyyy}"
                    HeaderText="Date Closed" HtmlEncode="False" SortExpression="DateClosed" />
                <%-----------------------Column - CaseNum----------------------------------------%>
                <asp:BoundField DataField="CaseNum" HeaderText="Case Num"
                    SortExpression="CaseNum" />
                <%-----------------------Column - ClientFileNumber-------------------------------%>
                <asp:BoundField DataField="ClientFileNumber" HeaderText="Client File #"
                    SortExpression="ClientFileNumber" />
                <%-----------------------Column - Upon1------------------------------------------%>
                <asp:BoundField DataField="Upon1" HeaderText="Upon1" SortExpression="Upon1" />
                <%-----------------------Column - Upon2------------------------------------------%>
                <asp:BoundField DataField="Upon2" HeaderText="Upon2" SortExpression="Upon2" />
                <%-----------------------Column - LastActivity-----------------------------------%>
                <asp:BoundField DataField="LastActivity" HeaderText="Last Activity"
                    SortExpression="LastActivity" />
                <%-----------------------Column - PapersExpire-----------------------------------%>
                <asp:BoundField DataField="PapersExpire" HeaderText="PapersExpire"
                    SortExpression="PapersExpire" Visible="false" />
                <%-----------------------Column - DateToPS---------------------------------------%>
                <asp:BoundField DataField="DateToPS" HeaderText="DateToPS"
                    SortExpression="DateToPS" Visible="false" />
            </Columns>
        </asp:GridView>



    Private Function GetClientSpkgs() As Integer
        Dim aQueryStr As String = Session("myWhereStmt")
        Dim SelectDate As String = "[tblServicePkg].DateIn >= CONVERT(VARCHAR(24), '" & DateAdd("d", -120, Now) & "', 102)"
        Dim spkgDAO As New tblServicePkgDAO

        'This function call returns a DataSet
        mySpkgDS = spkgDAO.GettblServicePkg(myQueryStr, SelectDate, orderby)
        gvClientSpkgList.DataSource = mySpkgDS.Tables(0)
        gvClientSpkgList.DataBind()
 
        If Session("SpkgNum") <> "" Then
            myApplyClientFilter(True)
        Else
            myApplyClientFilter(False)
        End If
    End Function



The new version is:
           <asp:GridView ID="gvClientSpkgList" runat="server" AllowPaging="True"
            AllowSorting="True" AutoGenerateColumns="False"
            OnPageIndexChanging="gvClientSpkgList_PageIndexChanging"
            OnSorting="gvClientSpkgList_Sorting" PagerSettings-Mode="NumericFirstLast"
            PageSize="30" Style="font-weight: 700">
            <PagerSettings Mode="NumericFirstLast" />
            <Columns>
                <%-----------------------Column - Show Attempts (only if Employee)--------------%>
                <asp:HyperLinkField DataNavigateUrlFields="ServicePkgID"
                    DataNavigateUrlFormatString="~/SecurePages/ClientSpkgAttempts.aspx?ServicePkgID={0}"
                    Text="Show Attempts" />
                <%-----------------------Column - Service Pkg ID--------------------------------%>
                <asp:BoundField DataField="ServicePkgID" HeaderText="ServicePkg"
                    InsertVisible="False" ReadOnly="True" SortExpression="ServicePkgID" />
                <%-----------------------Column - Status----------------------------------------%>
                <asp:TemplateField HeaderText="Status" SortExpression="ClientStatusID">
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server"
                            DataSourceID="SqlDataSourceClientStatus" DataTextField="ClientStatusText"
                            DataValueField="ClientStatusID" Enabled="False"
                            SelectedValue='<%# Bind("ClientStatusID") %>' Width="90px">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SqlDataSourceClientStatus" runat="server"
                            ConnectionString="<%$ ConnectionStrings:integrity_dbLocalConnectionString %>"
                            SelectCommand="GetClientStatuses" SelectCommandType="StoredProcedure">
                        </asp:SqlDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <%-----------------------Column - Assigned To (only in Admin view)---------------%>
                <asp:TemplateField HeaderText="Assigned To" SortExpression="Assignedto" Visible = "false">
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownListAssignTo" runat="server"
                            DataSourceID="SqlDataSourceAssignedto" DataTextField="empUserName"
                            DataValueField="empID" SelectedValue='<%# Bind("AssignedTo") %>' Width="90px">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SqlDataSourceAssignedto" runat="server"
                            ConnectionString="<%$ ConnectionStrings:integrity_dbLocalConnectionString %>"
                            SelectCommand="GetEmployeeNames" SelectCommandType="StoredProcedure">
                        </asp:SqlDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                <%-----------------------Column - DateIn-----------------------------------------%>
                <asp:BoundField DataField="DateIn" DataFormatString="{0:M/dd/yyyy}"
                    HeaderText="Date In" HtmlEncode="False" SortExpression="DateIn" />
                <%-----------------------Column - Date Closed------------------------------------%>
                <asp:BoundField DataField="DateClosed" DataFormatString="{0:M/dd/yyyy}"
                    HeaderText="Date Closed" HtmlEncode="False" SortExpression="DateClosed" />
                <%-----------------------Column - CaseNum----------------------------------------%>
                <asp:BoundField DataField="CaseNum" HeaderText="Case Num"
                    SortExpression="CaseNum" />
                <%-----------------------Column - ClientFileNumber-------------------------------%>
                <asp:BoundField DataField="ClientFileNumber" HeaderText="Client File #"
                    SortExpression="ClientFileNumber" />
                <%-----------------------Column - Upon1------------------------------------------%>
                <asp:BoundField DataField="Upon1" HeaderText="Upon1" SortExpression="Upon1" />
                <%-----------------------Column - Upon2------------------------------------------%>
                <asp:BoundField DataField="Upon2" HeaderText="Upon2" SortExpression="Upon2" />
                <%-----------------------Column - LastActivity-----------------------------------%>
                <asp:BoundField DataField="LastActivity" HeaderText="Last Activity"
                    SortExpression="LastActivity" />
                <%-----------------------Column - PapersExpire-----------------------------------%>
                <asp:BoundField DataField="PapersExpire" HeaderText="PapersExpire"
                    SortExpression="PapersExpire" Visible="false" />
                <%-----------------------Column - DateToPS---------------------------------------%>
                <asp:BoundField DataField="DateToPS" HeaderText="DateToPS"
                    SortExpression="DateToPS" Visible="false" />
            </Columns>
        </asp:GridView>



    Private Function GetClientSpkgs() As Integer
        Dim aQueryStr As String = Session("myWhereStmt")
        Dim SelectDate As String = "[tblServicePkg].DateIn >= CONVERT(VARCHAR(24), '" & DateAdd("d", -120, Now) & "', 102)"
        Dim spkgDAO As New tblServicePkgDAO

        'This function call returns a DataSet
        mySpkgDS = spkgDAO.GettblServicePkg(myQueryStr, SelectDate, orderby)
        gvClientSpkgList.DataSource = mySpkgDS.Tables(0)
        gvClientSpkgList.DataBind()
 
        If Session("SpkgNum") <> "" Then
            myApplyClientFilter(True)
        Else
            myApplyClientFilter(False)
        End If
    End Function



The fom loads.  The label says I have 77 records, But the dataView is not displaying at all.
What am I doing wrong?
Gail D.Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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

Randy DownsOWNERCommented:
Maybe this will help. Your data source is set in your function GetClientSpkgs.

   gvClientSpkgList.DataSource = mySpkgDS.Tables(0)
        gvClientSpkgList.DataBind()

Open in new window


Maybe try their sample code to see if it works better for you.
protected void Page_Load(object sender, EventArgs e)
 {
       if (!Page.IsPostBack)
       {
          gvBind(); //Bind gridview
       }
}

public void gvBind()
{    SqlDataAdapter dap = new SqlDataAdapter("select query", conn);
     DataSet ds = new DataSet();
     dap.Fill(ds);
     mygrid.DataSource = ds.Tables[0];
     mygrid.DataBind();
}

protected void PageIndexChanging(object sender, GridViewPageEventArgs e)
{
       mygrid.PageIndex = e.NewPageIndex;
       gvBind();
}

Open in new window

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
Gail D.Author Commented:
I have been looking for the SqlDataAdapter for two days.  OMG!  Thank-you!
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.