Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 24th, 2008, 08:16 AM
Registered User
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Index was out of range. Must be non-negative

HI,

I am facing some problem with image button. I found an event log error.I am not able to reproduce this when i tried,but it is logging in my event log.



Event time: 2008-05-04 08:53:57 PM -07:00
Event type: Error
Event source: Application
User:
Event ID: 0

The message '0' for application 'Application' could not be formatted using library(ies): ''. The log entry contains the following replacement strings:'***************************************** ***************************************Sunday, May 04, 2008Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index Error Guid:ac2fc6fe-0bd9-450d-8155-bbdd7479bf5b SOURCE:mscorlib STACK TRACE: at System.Collections.ArrayList.get_Item(Int32 index) at System.Web.UI.WebControls.DataGridItemCollection.g et_Item(Int32 index) at App_WebControls_Ctrl_ClientLookup.imgbtnCommClient ID_Command(Object sender, CommandEventArgs e)Please provide the cause.

Please find the below code and do needful.


protected void imgbtnCommClientID_Command(object sender, CommandEventArgs e)
 {
  if (!bIsTrackerPage)
  {
   try
   {

    objCtrl_ErrorSummary.ClearError();
    lblFindByName.CssClass = "form_item_text";
    DataSet dsClientQuotesPolicies = null;
    int nSelectedClientID = Casting.ToInt(e.CommandArgument);
    int nRowNumber = 0;
    int nPreviousRow = 0;

    if (hidSelectedRowNumber.Value != null)
    {
     nRowNumber = Casting.ToInt(hidSelectedRowNumber.Value);
    }
    if (hidPreviousRowNumber.Value != null)
    {
     nPreviousRow = Casting.ToInt(hidPreviousRowNumber.Value);
    }

    dsClientQuotesPolicies = objClientController.GetClientPoliciesandQuotes(nSe lectedClientID, 1);

    if (nPreviousRow > 0)
    {
                    if ((nPreviousRow != nRowNumber) && (grdComClientLookUp.Items.Count > (nPreviousRow - 1)))
     {
      ImageButton objimgPreviousRow = new ImageButton();
      objimgPreviousRow = (ImageButton)grdComClientLookUp.Items[nPreviousRow - 1].Controls[0].FindControl("imgbtnClientID");
      objimgPreviousRow.ImageUrl = "~/Images/icons/row_arrow_closed.gif";
      objPreviousComGrid = (DataGrid)grdComClientLookUp.Items[nPreviousRow - 1].Controls[0].FindControl("grdQuoteDetails");
      objPreviousComGrid.Visible = false;
     }
    }
                if ((nRowNumber > 0) && (grdComClientLookUp.Items.Count > (nRowNumber-1)))
                {
                    ImageButton objimgPresentRow = new ImageButton();
                    objimgPresentRow = (ImageButton)grdComClientLookUp.Items[nRowNumber - 1].Controls[0].FindControl("imgbtnClientID");
                    objimgPresentRow.ImageUrl = "~/Images/icons/row_arrow_open.gif";
                    objComClientDetails = (DataGrid)grdComClientLookUp.Items[nRowNumber - 1].Controls[0].FindControl("grdQuoteDetails");


    if (!UISupport.IsEmptyDataSet(dsClientQuotesPolicies) )
    {
     if (nPreviousRow != nRowNumber)
     {
      objComClientDetails.Visible = true;
      objComClientDetails.DataSource = dsClientQuotesPolicies;
      objComClientDetails.DataBind();
     }
    }
    else
    {
     objimgPresentRow.ImageUrl = "~/Images/icons/row_arrow_closed.gif";
    }
    if (nPreviousRow == nRowNumber && !UISupport.IsEmptyDataSet(dsClientQuotesPolicies))
    {
     if (objComClientDetails.Visible == true)
     {
      objComClientDetails.Visible = false;
      objimgPresentRow.ImageUrl = "~/Images/icons/row_arrow_closed.gif";
     }
     else
     {
      objComClientDetails.Visible = true;
      objimgPresentRow.ImageUrl = "~/Images/icons/row_arrow_open.gif";
     }
    }
            }
                //System.Diagnostics.Process obj = new System.Diagnostics.Process()

                if ((nRowNumber != -1) && (nRowNumber != nPreviousRow) && (grdComClientLookUp.Items.Count > (nRowNumber - 1)))
                {
                    grdComClientLookUp.Items[nRowNumber-1].CssClass = "GridSelectedStyle";
                    if ((nPreviousRow != -1) && (grdComClientLookUp.Items.Count > (nPreviousRow - 1)))
                    {
                        if (grdComClientLookUp.Items[nPreviousRow - 1].ItemType == ListItemType.AlternatingItem)
                            grdComClientLookUp.Items[nPreviousRow - 1].CssClass = "GridRowSelected";
                        else
                            grdComClientLookUp.Items[nPreviousRow - 1].CssClass = "GridRowUnselected";
     }
    }
   }
   catch (Exception ex)
   {
    UIExceptionManager.LogAndRedirect(ex, false, Context.Items["RequestID"].ToString());
   }
  }
 }

Thanks








Similar Threads
Thread Thread Starter Forum Replies Last Post
Index 0 is not non-negative! ktsis ASP.NET 1.0 and 1.1 Basics 1 July 5th, 2006 09:00 PM
index out of range datagrid muchengeti ASP.NET 2.0 Professional 0 April 21st, 2006 12:43 PM
Index Out of range exception PbsiGuru General .NET 3 March 22nd, 2004 11:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.