Missing first row when binding a reader to a repeater.

Eron Armour <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.web
Message-ID <[email protected]>
I have a method to search a user's course history. When searching with a
particular user and search string I get 2 rows back and this is correct.

 

I call a method GetSearchResults(int, string, int, int) and if that
reader has rows I pass some of the rows to another method,
BuildCourseURL(int, int, int, string) to build a url depending on the
test type which is passed to it.

 

Here's is my code:

 

                    SqlDataReader drHistory = search.GetSearchResults(4,
term, userKey, userGroupKey);

                    if (!drHistory.HasRows)

                    {

                        lblNothing.Visible = true;

                    }

                    else

                    {

                        if (drHistory.Read())

                        {

                            launchURL =
url.BuildCourseURL(Convert.ToInt32(drHistory["CourseKey"]),

 
Convert.ToInt32(drHistory["Media"]),

 
Convert.ToInt32(drHistory["CourseEventKey"]),

 
drHistory["TestType"].ToString());

                        }

 

                            repTrainingHistory.DataSource = drHistory;

                            repTrainingHistory.DataBind();

                            repeaterSearchResults.Visible = false;

                            repTrainingHistory.Visible = true;

                            repTraining.Visible = false;

                            repeaterSearchResults.Visible = false;

                            lblNothing.Visible = false;

                    }

 

Everything works as it should and I get 2 results passed back but when
the datareader is bound to the repreater (I think it is at this point)
I'm missing the first row. Here's the front end code:

 

    <asp:Repeater ID="repTrainingHistory" runat="server">

        <HeaderTemplate>

            <table border="0" cellpadding="5" cellspacing="0"
width="100%">

                <tr>

                    <td
width="250px"><strong><em>Source</em></strong></td>

                    <td><strong><em>Result</em></strong></td>

                    <td>Date</td>

                </tr>

        </HeaderTemplate>

            <ItemTemplate>

            <tr>

                <td colspan="3"><hr noshade size="1" /></td>

            </tr>

            <tr>

                <td><%# getCategoryText(category)%></td>

                <td>

                <a href="javascript:void(0);" onclick=<%# launchURL
%>><%# Eval("Title")%></a>

                <td><%# Eval("Date") %></td>

            </tr>

            </ItemTemplate>

        <FooterTemplate>

            </table>

        </FooterTemplate>

    </asp:Repeater>

 

Any help would be greatly appreciated.

 


===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.