Bug Found + Fix

Last post 02-27-2009 6:11 AM by misuk11. 4 replies.

Sort Posts:

  • Bug Found + Fix

    05-27-2006, 1:00 AM
    • Contributor
      2,898 point Contributor
    • jminond
    • Member since 07-21-2003, 6:33 PM
    • New York
    • Posts 608
     Here is an error... below it i have a fix....

    Server Error in '/configtest' Application.

    Attempted to divide by zero.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.DivideByZeroException: Attempted to divide by zero.

    Source Error:

    Line 154:                    for (int iItem = 0; iItem < dataList.Items.Count; iItem++)
    Line 155:                    {
    Line 156:                        int nRow = iItem / dataList.RepeatColumns;
    Line 157:                        int nCol = iItem % dataList.RepeatColumns;
    Line 158:                        int nDesiredIndex = iItem;


    Source File: C:\Documents and Settings\Jonathan\Desktop\wwAppConfiguration\wwAppConfiguration\UI\WebControls\Adapters\DataListAdapter.cs    Line: 156

     

    This is the if around this.... and the replacement code (for me line 146-207)

    The key to the problem is the repeatcolumns when= 0 there was no checking for this... so i made a simple bool

    bool haveItems = (dataList.RepeatColumns > 0) ? true : false;

    and everywhere that used repeaatcolkms, i but an haveItems && so that the boolean check is first.

    if

    (dataList.ItemTemplate != null)

    {

    writer.WriteLine();

    writer.WriteBeginTag(

    "tbody");

    writer.Write(

    HtmlTextWriter.TagRightChar);

    writer.Indent++;

    int nItemsInColumn = (int)Math.Ceiling(((Double)dataList.Items.Count) / ((Double)dataList.RepeatColumns));

    bool haveItems = (dataList.RepeatColumns > 0) ? true : false;

    for (int iItem = 0; iItem < dataList.Items.Count; iItem++)

    {

    int nRow = (haveItems) ? (iItem / dataList.RepeatColumns) : 0;

    int nCol = (haveItems) ? (iItem % dataList.RepeatColumns) : 0;

    int nDesiredIndex = iItem;

    if (dataList.RepeatDirection == RepeatDirection.Vertical)

    {

    nDesiredIndex = (nCol * nItemsInColumn) + nRow;

    }

    if (haveItems && (iItem % dataList.RepeatColumns) == 0)

    {

    writer.WriteLine();

    writer.WriteBeginTag(

    "tr");

    writer.Write(

    HtmlTextWriter.TagRightChar);

    writer.Indent++;

    }

    writer.WriteLine();

    writer.WriteBeginTag(

    "td");

    writer.Write(

    HtmlTextWriter.TagRightChar);

    writer.Indent++;

    foreach (Control itemCtrl in dataList.Items[iItem].Controls)

    {

    itemCtrl.RenderControl(writer);

    }

    writer.Indent--;

    writer.WriteLine();

    writer.WriteEndTag(

    "td");

    if (haveItems && ((iItem + 1) % dataList.RepeatColumns) == 0)

    {

    writer.Indent--;

    writer.WriteLine();

    writer.WriteEndTag(

    "tr");

    }

    }

    if (haveItems && (dataList.Items.Count % dataList.RepeatColumns) != 0)

    {

    writer.Indent--;

    writer.WriteLine();

    writer.WriteEndTag(

    "tr");

    }

    writer.Indent--;

    writer.WriteLine();

    writer.WriteEndTag(

    "tbody");

    }

    Jonathan Minond
    http://www.Jonavi.com
    http://www.jonavi.com/Default.aspx?pageID=21
    http://RainbowBeta.com
    http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
    http://dotnetslackers.com/community/blogs/jminond/default.aspx
  • Re: Bug Found + Fix

    05-27-2006, 1:41 AM
    • Contributor
      3,298 point Contributor
    • Russ Helfand
    • Member since 09-14-2005, 6:22 PM
    • Groovybits.com
    • Posts 741
    Thanks for reporting this.  I'm sorry about the inconvenience that this has caused.  Please refer also to http://forums.asp.net/thread/1290684.aspx and http://forums.asp.net/thread/1275928.aspx.  This fix will be in the next release of the kit.  Your workaround for now is fine.  Thanks for offering it to the community!
    Russ Helfand
    Groovybits.com
  • Re: Bug Found + Fix

    05-27-2006, 2:42 AM
    • Contributor
      2,898 point Contributor
    • jminond
    • Member since 07-21-2003, 6:33 PM
    • New York
    • Posts 608
    No problem!
    Jonathan Minond
    http://www.Jonavi.com
    http://www.jonavi.com/Default.aspx?pageID=21
    http://RainbowBeta.com
    http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
    http://dotnetslackers.com/community/blogs/jminond/default.aspx
  • Re: Bug Found + Fix

    05-27-2006, 10:03 PM
    • Contributor
      3,298 point Contributor
    • Russ Helfand
    • Member since 09-14-2005, 6:22 PM
    • Groovybits.com
    • Posts 741
    Please refer to this thread, http://forums.asp.net/thread/1298405.aspx, for more information....
    Russ Helfand
    Groovybits.com
  • Re: Bug Found + Fix

    02-27-2009, 6:11 AM
    • Participant
      1,282 point Participant
    • misuk11
    • Member since 08-05-2003, 2:40 AM
    • Posts 747

    where can i get the fix for this ?  Ive just installed version 24242 and I still get the problem

Page 1 of 1 (5 items)