Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Error with formView linked to ObjectDataSOurce that returns no data

Posted on 2009-05-12
3
1,349 Views
Last Modified: 2013-12-17
Greetings all

I have a FormView, linked to an ObjectDataSource that gets it's data from a method in the business layer, which calls a stored procedure. This works fine. I then changed the stored proc, so that NO data is returned, for further testing.

The app falls over, complaining of an out of bounds index (see Error message and Page Source attached).

Any thoughts?


In advance, thanks!!!

    allanmark
EROR:
 
 Index was outside the bounds of the array.
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.IndexOutOfRangeException: Index was outside the bounds of the array.
 
Source Error:
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
 
Stack Trace:
 
[IndexOutOfRangeException: Index was outside the bounds of the array.]
   System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +196
 
[Exception:  is not a valid value for Int32.]
   System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) +610
   System.ComponentModel.TypeConverter.ConvertFromString(ITypeDescriptorContext context, CultureInfo culture, String text) +42
   System.ComponentModel.TypeConverter.ConvertFromInvariantString(String text) +62
   System.Web.UI.WebControls.ObjectDataSourceView.ConvertType(Object value, Type type, String paramName) +152
   System.Web.UI.WebControls.ObjectDataSourceView.BuildObjectValue(Object value, Type destinationType, String paramName) +262
   System.Web.UI.WebControls.ObjectDataSourceView.GetResolvedMethodData(Type type, String methodName, IDictionary allParameters, DataSourceOperation operation) +2033
   System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +3163
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +94
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +205
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +125
   System.Web.UI.WebControls.FormView.DataBind() +28
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +104
   System.Web.UI.WebControls.FormView.EnsureDataBound() +209
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +127
   System.Web.UI.Control.EnsureChildControls() +140
   System.Web.UI.Control.PreRenderRecursiveInternal() +124
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4774
 
 
 
SOURCE:
 
<%@ Page Language="C#" MasterPageFile="~/MimeMaster01.master" AutoEventWireup="true" CodeFile="People.aspx.cs" Inherits="People" Title="People" %>
<%@ MasterType VirtualPath="~/MimeMaster01.master" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="leftnav" Runat="Server" >  
 
    <center>
    <ajaxext:UpdatePanel ID="uppnlSelector" runat="Server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:Panel ID="pnlSelector" runat="Server">
        <asp:Panel ID="pnlSelOptions" runat="server" GroupingText=" Which records? " Width="200px" 
                   Height="65px" CssClass="smallGroupText" HorizontalAlign="Left">
            <asp:CheckBox ID="chkActive" runat="server" Text="Current ME members" Checked="true" CssClass="smallGroupText" AutoPostBack="true" OnCheckedChanged="chkActive_CheckedChanged" />   
            <br />
            <asp:CheckBox ID="chkInvolved" runat="server" Text="Involved in ME" Checked="true" CssClass="smallGroupText" AutoPostBack="true" OnCheckedChanged="chkInvolved_CheckedChanged" />    
        </asp:Panel>    
        <br />
    
        <asp:ListBox ID="lbxCouples" runat="server" CssClass="listbox" OnSelectedIndexChanged="lbxCouples_SelectedIndexChanged" AutoPostBack="True">    
        </asp:ListBox>
        <ajaxToolkit:ListSearchExtender ID="ajaxLstCouples" runat="server" TargetControlID="lbxCouples" PromptCssClass="ListSearchExtenderPrompt" ></ajaxToolkit:ListSearchExtender>
    </asp:Panel>
    <!-- <asp:Panel ID="pnlSelector" > -->
    </ContentTemplate>
    </ajaxext:UpdatePanel>
    
    </center>
        
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="rightnav" Runat="Server">
 
    <ajaxext:UpdatePanel ID="uppnlSpousal" runat="server" UpdateMode="Conditional">
    <ContentTemplate>    
        
    <asp:Panel ID="pnlSpousalTitle" runat="server" CssClass="collapsePanelHeader"> 
        <asp:Image ID="imgCollapse" runat="server" ImageUrl="~/Graphics/expand.jpg"/>&nbsp;&nbsp;
            Spousal Details&nbsp;&nbsp;        
        <asp:Label ID="Label1" runat="server">(Show Details...)</asp:Label>
        <br />
    </asp:Panel><br />
    
    <asp:Panel ID="pnlSpousalContent" runat="server" CssClass="collapsePanel">        
 
       <ajaxToolkit:CollapsiblePanelExtender ID="cpe01" runat="Server" 
            TargetControlID="pnlSpousalContent"
            ExpandControlID="imgCollapse" 
        </ajaxToolkit:CollapsiblePanelExtender>
 
     
        <a name="theSpousalTop" ></a>  
                
        <br />
        
        <asp:FormView  ID="fvSpousal" runat="server" DefaultMode="ReadOnly" OnDataBound="fvSpousal_DataBound" DataSourceID="spousalODS"
                EnableViewState="true" DataKeyNames="C_Id,SP1_Id,SP2_Id" CssClass="smallFontSize" OnModeChanging="fvSpousal_ModeChanging" 
                OnItemCommand="fvSpousal_ItemCommand" OnItemUpdating="FvSpousal_ItemUpdating"  OnItemInserting="FvSpousal_ItemInserting">  
 
               
                <ItemTemplate>
                 <ajaxToolkit:ConfirmButtonExtender ID="cbe" runat="server"
            TargetControlID="btnDeleteI"
            ConfirmText="Are you sure you want to delete this couple?"  />
                &nbsp;&nbsp;
                <asp:Button ID="btnEditI"   runat="Server" Text="Edit" CssClass="buttons"  CommandName="EDIT"  />
                &nbsp;&nbsp;
		.....................
                <br />                
            </ItemTemplate> 
             
            <EditItemTemplate>
                &nbsp;&nbsp;
                <asp:Button ID="btnUpdateE"   runat="Server" Text="Update" CssClass="buttons"  CommandName="Update" />
                &nbsp;&nbsp;
		..................
                <br />        
            </EditItemTemplate>
                                       
        </asp:FormView>                       
        
    </ContentTemplate>
    </ajaxext:UpdatePanel>              
    <br />
 
        <asp:ObjectDataSource ID="spousalODS" runat="Server" TypeName="BusinessLogic.Business" DataObjectTypeName="DataTransferObjects.SpouseODS_DO"
            SelectMethod="GetCouple" UpdateMethod="SpousalODS_Update"  InsertMethod="SpousalODS_Insert" DeleteMethod="SpousalODS_Delete"
            OnSelected="spousalODS_Selected" OnSelecting="spousalODS_Selecting" OnUpdated="SpousalODS_Updated" OnInserted="SpousalODS_Inserted"
             OnDeleted="SpousalODS_Deleted"
     OldValuesParameterFormatString="{0}"  >
            <SelectParameters >
               <asp:QueryStringParameter Name="CoupleId"   DbType="Int32" Direction="Input"  />
            </SelectParameters>           
            <InsertParameters>
            <asp:Parameter Name="@newCoupleId" Direction="Output" Type="Int32" />
            </InsertParameters>
         </asp:ObjectDataSource>  
         
    <asp:ObjectDataSource ID="portfolioODS" runat="Server" SelectMethod="GetPortfolios" TypeName="BusinessLogic.Business">
    </asp:ObjectDataSource>    
    <asp:ObjectDataSource ID="titleODS" runat="Server" SelectMethod="GetTitles" TypeName="BusinessLogic.Business">
    </asp:ObjectDataSource>    
    
</asp:Content>

Open in new window

0
Comment
Question by:allanmark
3 Comments
 
LVL 12

Expert Comment

by:GuitarRich
ID: 24364962
how did you change the stored proc? does it now return an empty resultset or does it just return out of the stored proc without returning any data? You'll need at least an empty resultset for the page to work ok I think.
0
 
LVL 7

Accepted Solution

by:
zwei earned 250 total points
ID: 24365018
Exception:  is not a valid value for Int32.
You're trying to store a value to an int that is not an int somewhere.

I think it's line 137:

<asp:QueryStringParameter Name="CoupleId"   DbType="Int32" Direction="Input"  />

Open in new window

0
 

Author Closing Comment

by:allanmark
ID: 31580544
Spot on!! Many thanks!!!
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question