PDA

View Full Version : Query not displaying complete data


user65
05-26-2010, 06:26 PM
Forewarning: I am working with a site that I didn't develop, and I also am not highly experienced with asp, please bear with me. :thumbsup:

I have a cms built in visual studio 2005. It is a news type website which features articles and such.

My problem is that the archive section has an issue in which it doesn't display the entire author's archive. I've looked at the database and can see the author's entire archive of articles dating back to 1997. I've compared the rows between the articles that appear, and don't appear and cannot see a difference - all the data seems to correlate correctly. The article archive cuts off at 2007 for some reason.

Here is the aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="bioAuthor.aspx.cs" Inherits="bioAuthor"
MasterPageFile="~/Main.master" EnableEventValidation="false" ValidateRequest="false" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ MasterType TypeName="Main" %>
<%@ Register Src="~/ctrlGenericPageRightSection.ascx" TagName="rightSection" TagPrefix="cc2" %>
<asp:Content ContentPlaceHolderID="PageContent" ID="cntMain" runat="Server">
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td valign="top">
<div class="headerBar">
FrontPageMag Columnist
</div>
<br />
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td id="tdImage" valign="top" runat="server">
<img style="padding-right: 5px" id="imgAuthor" alt="" runat="server" />
</td>
<td valign="top" width="100%">
<asp:Label ID="lblName" runat="server" CssClass="genericHeader"></asp:Label>
<asp:Label ID="lblBio" runat="server"></asp:Label><br />
</td>
</tr>
<tr>
<td colspan="3">
<hr />
</td>
</tr>
<tr>
<td colspan="3">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left">
<span class="genericHeader">Related Articles</span></td>
<td align="right">
<asp:UpdateProgress id="updPrgress" runat="server" AssociatedUpdatePanelID="updAuthor">
<progresstemplate>
<div class="progressBar">
</div>
</progresstemplate>
</asp:UpdateProgress>
</td>
</tr>

</table>
<asp:UpdatePanel ID="updAuthor" runat="Server">
<contenttemplate>
<DIV><asp:GridView id="gvAuthorArticle" runat="Server" HeaderStyle-CssClass="hiddenHeaderRow" PagerStyle-HorizontalAlign="Right" PagerSettings-Position="TopAndBottom" PagerSettings-Mode="NextPrevious" OnPageIndexChanging="gvAuthorArticle_PageIndexChanging" GridLines="none" AllowPaging="true" OnRowDataBound="gvAuthorArticle_RowDataBound" BorderWidth="0" Width="100%" AutoGenerateColumns="false">
<PagerSettings Mode="NextPrevious" NextPageImageUrl="~/images/next1.JPG" NextPageText="" Position="TopAndBottom" PreviousPageImageUrl="~/images/prev1.JPG" PreviousPageText=""></PagerSettings>

<EmptyDataRowStyle HorizontalAlign="Center" ForeColor="Red"></EmptyDataRowStyle>
<Columns>
<asp:TemplateField><ItemTemplate>
<asp:Label ID="lblArticleTitle" runat="server" CssClass="articleHeader"></asp:Label>
<asp:Label ID="lblPubDate" runat="server" CssClass="articleSubtext"></asp:Label>

</ItemTemplate>
</asp:TemplateField>
</Columns>

<PagerStyle HorizontalAlign="Right"></PagerStyle>
<EmptyDataTemplate>
<span>Record not found !</span>

</EmptyDataTemplate>

<HeaderStyle CssClass="hiddenHeaderRow"></HeaderStyle>
</asp:GridView></DIV>
</contenttemplate>
</asp:UpdatePanel>
</td>
</tr>
</tbody>
</table>
</td>
<td valign="top" width="360">
<cc2:rightSection ID="rightSection" runat="server"></cc2:rightSection>
</td>
</tr>
</tbody>
</table>
</asp:Content>


Here is the aspx.cs:

public partial class bioAuthor : System.Web.UI.Page
{
ConnectionManager mgr;
Author au = new Author();
int ArticleID = 0;
int AuthorID = 0;
int ASPDbID = 0;
DateTime PublishDate;
int PageLimit = 0;
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
mgr = new ConnectionManager();
int.TryParse(Request["ID"], out ASPDbID);
if (Request["ID"] != "" && Request["ID"] != null)
{
if (ASPDbID != 0)
{
ds = mgr.ExecuteQuery("up_Author_GetByASP_DB_ID " + ASPDbID + "", "tbl");
if (ds.Tables[0].Rows.Count != 0)
{
Response.Redirect("bioAuthor.aspx?AUTHID=" + ds.Tables[0].Rows[0]["AUTHOR_ID"] + "");
}
}
}

if (Request["GUID"] != "" && Request["GUID"] != null)
{
if (!Helpers.CheckTextInput(Request["GUID"])) return;
ds = mgr.ExecuteQuery("up_Author_GetByGUID '" + Request["GUID"] + "'", "tbl");
if (ds.Tables[0].Rows.Count != 0)
{
Response.Redirect("bioAuthor.aspx?AUTHID=" + ds.Tables[0].Rows[0]["AUTHOR_ID"] + "");
}
}
int.TryParse(Request["AUTHID"], out AuthorID);
if (!IsPostBack)
BindData();
}
private void BindData()
{
mgr = new ConnectionManager();
DataSet ds = new DataSet();
int.TryParse(Request["AUTHID"], out AuthorID);
if (AuthorID != 0)
{
au.Load(AuthorID);
Page.Title = "FrontPage Magazine - " + au.FirstName + " " + au.LastName;
lblName.Text = au.FirstName + " " + au.LastName;
lblBio.Text = au.Bio;
if (au.Picture != null && au.Picture != "")
{
imgAuthor.Src = "/media/" + au.Picture;
}
else
{
tdImage.Visible = false;
}
ds = mgr.ExecuteQuery("up_Articles_GetALL " + AuthorID + ",0,'','',0", "tbl");
if (ds.Tables.Count != 0)
{
PageLimit = Convert.ToInt32(ConfigurationManager.AppSettings["recordsPerPage"]);
gvAuthorArticle.PageSize = PageLimit;
gvAuthorArticle.DataSource = ds.Tables[0];
gvAuthorArticle.DataBind();
}
}
}
protected void gvAuthorArticle_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.DataRow) return;
Label lblArticleTitle = (Label)e.Row.FindControl("lblArticleTitle");
Label lblPubDate = (Label)e.Row.FindControl("lblPubDate");

int ArticleId = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "ARTICLE_ID"));
string linkStr = string.Empty;

if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "URL")).Length<=0)
{
linkStr = "<a href='readArticle.aspx?ARTID=" + ArticleId + "'>";
}
else
{
linkStr = "<a href='" + DataBinder.Eval(e.Row.DataItem, "URL") + "' target='_new'>";
}

if (DataBinder.Eval(e.Row.DataItem, "TITLE") != DBNull.Value)
{
lblArticleTitle.Text = linkStr + Convert.ToString(DataBinder.Eval(e.Row.DataItem, "TITLE")) + "</a>";
}
PublishDate = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "PUB_DATE"));
lblPubDate.Text = "Published: " + PublishDate.ToLongDateString();
}
protected void gvAuthorArticle_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvAuthorArticle.PageIndex = e.NewPageIndex;
BindData();
}
}


I'm not sure if posting the code helps or not, but any help would be appreciated.

Thank you.

Old Pedant
05-26-2010, 07:24 PM
Well, first of all, this is an ASP.NET question, not an ASP question.

But secondly, I don't think you are going to find the answer in that ASP.NET code. I *think* (not sure, but probably) that the problem is in the Stored Procedures that the .NET code is invoking. *PROBABLY* specifically in this SP:
up_Articles_GetALL

So if you don't know how to read and alter SQL Server stored procedures, you will probably need the help of a database manager or similar. Hope you have one available to you.

Almost certainly this is true if the part of the page with the problem is the one that says
Published: January 7, 2007

(or whatever date is actually displayed).