if (drHistory.Read())
this line advances to the next record, thats why the first record is
not shown in your repeater.
Why don't you make up your lauch url within the template itself?
<a href="javascript:void(0);" onclick=<%#
url.BuildCourseURL((int)Eval("CourseKey"),(int)Eval("Media"),(int)Eval("CourseEventKey"),(string)Eval("TestType"))
%> ><%# Eval("Title") %></a>
HTH
// Ryan
On 4/17/07, Eron Armour <***@nanmckay.com> wrote:
> 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(r) http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com