Asked by:
Bug Found + Fix

Question
-
User-1639143169 posted
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: 156This 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");}
Saturday, May 27, 2006 1:00 AM
All replies
-
User-534056067 posted
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!Saturday, May 27, 2006 1:41 AM -
User-1639143169 posted
No problem!Saturday, May 27, 2006 2:42 AM -
User-534056067 posted
Please refer to this thread, http://forums.asp.net/thread/1298405.aspx, for more information....Saturday, May 27, 2006 10:03 PM -
User65893105 posted
where can i get the fix for this ? Ive just installed version 24242 and I still get the problem
Friday, February 27, 2009 6:11 AM