Forms Data Controls :: ObjectDataSourceView.BuildDataObject Throwing IndexOutOfRangeException?
Jan 27, 2010
I've got a FormView bound to an ObjectDataSource. The FormView/ODS selects and displays my data correctly but when I change the data and try to update,nothing (seemingly) happens.Stepping through the code and digging deeper into the stack trace and output window,I figured out that the following sequence of events happens:
- The ObjectDataSource drills down to System.Web.UI.WebControls.ObjectDataSourceView.BuildDataObject to create the object I specified in the "DataObjectTypeName" property
[code]...
- Here is where the IndexOutOfRangeException happens. Sometimes one or two of the data object's properties will be set, sometimes none. Either way, the exception is thrown and the sequence is stopped (the business object's update is never called).
- The exception is not thrown inside any of the properties' set methods.I'm assuming that the exception is happening when BuildDataObject is using Reflection to find my data object's properties (GetProperty() etc.. ). Since I can't see the source code of BuildDataObject and the debugger won't give me any more information, there is no way for me to see which property (if any) is causing this.I double checked the names and types of all 27 of the data object's properties.
View 1 Replies
Similar Messages:
Nov 30, 2010
I'm trying to do a master-detail by first search the database when a user click on the search button. Then display the result to a ListView control. After that, if the user click on the hyperlink, it displays the detail on the Formview control. Below are my code:
[Code]....
And here's the part that causes the error:
[Code]....
The error is on this line: string strID = ltvLusHmoob.DataKeyNames[e.Item.DataItemIndex].ToString();
View 9 Replies
Apr 3, 2010
Server Error in '/EBOOKS' Application.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
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.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
Line 61: Dim favorname As String = GridView1.DataKeys(row.RowIndex).ToStringLine 62: Line 63: ' Pass the value of the selected Employye ID to the Delete //command. My coding as
Protected Sub btnMultipleRowDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnMultipleRowDelete.Click
' Looping through all the rows in the GridView
For Each row As GridViewRow In GridView1.Rows
Dim checkbox As CheckBox = CType(row.FindControl("cbRows"), CheckBox)
'Check if the checkbox is checked.
'value in the HtmlInputCheckBox's Value property is set as the //value of the delete command's parameter.
If checkbox.Checked Then
' Retreive the Favorname
Dim favorname As String = GridView1.DataKeys(row.RowIndex).ToString
' Pass the value of the selected Employye ID to the Delete //command.
SqlDataSource1.DeleteParameters("Favorname").DefaultValue = favorname.ToString()
SqlDataSource1.Delete()
End If
Next row
End Sub
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
Width="563px" AutoGenerateColumns="False">
<RowStyle CssClass="fontsmallthennormal" />
<HeaderStyle CssClass="fontnormalblue8" />
<EditRowStyle CssClass="fontsmallthennormal" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="cbRows" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Favorname" HeaderText="Favorname" SortExpression="Favorname" />
<asp:BoundField DataField="FavorDate" HeaderText="FavorDate" SortExpression="FavorDate" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1"
ConnectionString="<%$ ConnectionStrings:yyyy %>"
runat="server" SelectCommand="SELECT [US], [Favorname], [FavorDate] FROM [TBL_FAVORITES] WHERE ([US] = @US)"
DeleteCommand="DELETE from TBL_FAVORITES where [Favorname]= @Favorname"
>
<SelectParameters >
<asp:ControlParameter ControlID="txtusername1" Name="US" PropertyName="Text" Type="String" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="Favorname" />
</DeleteParameters>
</asp:SqlDataSource>
View 5 Replies
Mar 1, 2010
Manually Adding GridViewRow Throwing Off Viewstate
View 6 Replies
Jul 13, 2010
A dataview is throwing an out of range exception when a page submit button is clicked. The strange part is if you change the data in the dataview by selecting a different person in the DDL the page works fine. Its only when the page loads and the default person in the DDL is when the DataView throws the exception.
The exception is thrown on the last line when I add DV.Rows(0).Cells(1).Text to the id_num parameter. I know there is a value in the dataview because it is displayed on the page. I can refresh the dataview with another person's information and the code works fine. This really has me confused. Here is a bit of the code behind.
Dim dashDataSource
As
New
SqlDataSource()
dashDataSource.ConnectionString =
ConfigurationManager.ConnectionStrings("SSSConnectionString2").ToString()
dashDataSource.InsertCommandType =
SqlDataSourceCommandType.Text
dashDataSource.InsertCommand =
"INSERT INTO tblAcadReferrals(all columns and parameter info here)"
dashDataSourceInsertParameters.Add("id_num", DV.Rows(0).Cells(1).Text)
View 7 Replies
Jan 27, 2010
Can anyone tell me why I get this error:
I'm trying to output my query results:
SELECT * FROM sites LEFT JOIN pages ON sites.siteid=pages.siteid LEFT JOIN subpages ON Pages.pageid=subpages.pageid WHERE sites.siteID = 1 ORDER BY sites.siteid ASC
using the code:
[code]....
Source Error:
[Code]....
Line 35: Line 36: While reader.Read()Line 37: mydata &= reader.Item("sitename") & " " & reader.Item("pageid") & " " & reader.Item("pagetitle") & "<br>" & reader.Item("subpages.pageid")Line 38: Line 39:
View 14 Replies
Jan 19, 2011
I am getting this error"System.IndexOutOfRangeException: There is no row at position 0." same code and concept working fine in 2 websites i could not able to solve this,only difference between current implementation and earlier implementation database,previously i used MySql database and now Ms-Excel data.I debugged data set is retreiving Code
Protected Sub chkSelect_CheckedChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim indx As Integer
Dim strExcelConn As String =
[code...]
View 3 Replies
Oct 12, 2010
I am getting 'indexOutofRangeException occurred' error - 'FixedActual'
SqlDataReader dataReader = null;
SqlCommand Scmd = new SqlCommand("SalesGetRecalcOrderItemCosts", this._connection);
Scmd.CommandType = System.Data.CommandType.StoredProcedure;
[code]...
View 1 Replies
Oct 19, 2010
I'm trying to get data from a CSV file and add it directly into a database using Linq.
I'm using the following code:
[Code]....
The code works if I remove all the but the first property e.g.
[Code]....
But then I get the old "System.IndexOutOfRangeException: Index was outside the bounds of the array." exception when adding more columns.
View 1 Replies
Dec 15, 2010
I have the following web service:
[ScriptService]
public class Handler : WebService {
[WebMethod]
public void method1() {
string json = "{ "success": true }";
System.Web.HttpContext.Current.Response.Write(json);
[code]...
The first method accepts a traditional html form post and response writes a JSON string to the page.The second method accepts a JSON value posted via AJAX and returns a serialized object.Both these methods work fine on their own but when put together in the same web service I get this error when calling method1:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
When I remove the arguments from method2 they work.Can anyone suggest why this is happening?
Edit:The problem spans from the argument type of method2. If I change it to a string or simple data type it works fine.As Joel suggests it's probably because Dictionaries can't be serialized.This doesn't seem to affect my requests sent by ajax and only breaks direct form posts to this handler.Therefore my workaround is to put the form post handlers in a separate file by themselves.Not ideal but works for my application.
View 1 Replies
Feb 9, 2010
I am having a little trouble with an 'IndexOutOfRangeException'. I think it is because when the code tries to get the DateModified col from the database it sometimes contains NULLS (the users haven't always updated the page since they created it).
Here is my code;
s = ("select datemodified, maintainedby, email, hitcount from updates where id = @footid")
Dim x As New SqlCommand(s, c)
x.Parameters.Add("@footid", SqlDbType.Int)
x.Parameters("@footid").Value = footid
c.Open()
Dim r As SqlDataReader = x.ExecuteReader
While r.Read
If r.HasRows Then
datemodified = (r("DateModified"))
maintainedby = (r("maintainedby"))
= (r("email"))
hitcount = (r("hitcount"))
End If
End While
c.Close()
I thought (after a bit of msdn) that adding;
If r.HasRows Then
End If
after adding I am still getting the same old IndexOutOfRangeException
(ps, I have tried datemodified as string / datetime)
View 4 Replies
Oct 13, 2010
Requirement:I have 2 tabs in the 2 tab i have a text box in that i have to select date today or before for that i am using ajax calendar control.
Problem: If i select a date below 11 in the calendar control it is not throwing error but if i select a date from 11 and above it is throwing a error.
My Compare validator code is below.
<asp:CompareValidator ID="Compdatefrom" runat="server" ControlToValidate="txtperiodfrom" ValidationGroup="Erradd" valuetocompare="<%#DateTime.Now.ToShortDateString() %>" Operator="LessThanEqual" type="date" ErrorMessage="Invalid Date"></asp:CompareValidator>
View 4 Replies
Nov 3, 2010
I m uploading file to a directory inside my website root directory like this-
[Code]....
I m getting exception-
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:Documents and SettingsAdminMy DocumentsVisual Studio 2008WebSitesElcomponics Sales-BDsamples�50841010_sd113201031833.pdf'.
Why so?
When i deployed my app on server and accessed it from client system. It is not throwing exception.What is the difference?
Still i want to confirm will it throw the same exception in case i deployed it to server and access it from client.
View 3 Replies
Aug 4, 2010
I am getting the following error and .Net master how to solve or getrid from this error
eg: datareader["ColumnName"];-----------------> i am getting error on this line
View 5 Replies
Apr 15, 2010
What is the point of throwing an exception? It it anyways going to be caught in the Global.asax Application_Error method.
Lets say in the following code we throw an exception.
try {
using (var dc = GetDataContext())
{
// We are doing some data inserts here.
}
catch ( Exception ex)
{
throw ex;
}
My Question: Even if we do not use try catch and throw here, any exception which will be raised here will be caught inside Application_Error method in Global.asax. Then what is the point of try, catch and throw in this case?
View 7 Replies
Feb 25, 2010
I tried to post data to client HTTPPost URL, as per the client specification I need to post the data using "Post" method and I used the same. But it throws an error "The remote server returned an error: (500)Internal Server Error". in the HTTpWebResponse.My post URL does not have any specific page like http://abc.com/post/post.aspx. the actual URL looks like "http://abc.com/post", Can we post the lead without any specific page like I said in the above URl?
View 2 Replies
Oct 1, 2010
I am trying to throw an ApplicationException in my else statement. the error I am getting is that ApplicationException was unhandled by user code. Shouldn't the Exception just bubble up and then being handled by my exception handling code?
if()
{
}
else
{
string errorMessage =
String.Format("PayPal IPN Transaction Type not found - PayPal_SubscriptionID = {0} UserID
= {1}", _ppp.Subscr_ID, _ppp.Custom);throw
new
ApplicationException(errorMessage);
}
View 2 Replies
Feb 3, 2010
I have an asp.net application with separate classes for business logic and database interaction and then of course the UI. I am building a form to add a widget to a widget list table in the database. My UI collects the information and submits it to the business class. I'm going to write the business class to first double check that the widget has a name (I know I should do this in UI with validation, and I will, but this is just in case validation is forgotten) and if it does, go ahead and send the information to the database class. The database class will then attempt to write the info to the correct table using a try catch finally block. Any errors caught here are logged and then rethrown so I can inform the user. So, knowing that my database class may rethrow an error, my business class code will also be written in a try catch finally block.
So at this point I have a number of possible outcomes that I want to inform the user via the UI:
1) Everything was fine and the widget was added.
2) Something happened with the database write and the user should try again later.
3) The user forgot to name the widget.
My question is: should I write my UI in a try catch block and then throw a custom Exception with an Exception.Message in the business layer if anything goes wrong, or just have my business logic return a string that is the message? I'll want to know if the process was successful or not, because I'll want to format the actual message differently, so I'd have to use if...elseif to determine if the message was bad or not.
It seems like throwing a custom Exception in the business layer may be a good way to tell the UI something bad happened. If the UI doesn't catch anything then of course the operation was successful. Then again throwing an exception for missing data seems a bit hefty.
View 6 Replies
Nov 19, 2010
I am using Substring method on a string variable.
Code:
fileName.Substring(67, 18)
I get this error
System.ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length
Don't know the reason. I debugged a lot and going crazy about this error.
View 6 Replies
Jan 17, 2011
We have an array of about 12 servers serving a website. Over the past few hours, one single server has started throwing exceptions for WebResource.axd and ScriptResource.axd requests.
Exception
System.Web.HttpException - This is an invalid script resource request.
Stack Trace
at System.Web.Handlers.ScriptResourceHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Broken server URL
/WebResource.axd?d=S6kjkBsrIKni9uO5HCkv0c8eYObzibWXn9R6A7Yr_Fy7CW4dRFZm1HfcnUTEZ8xBYZDM-5zeTVk1tTgC1hp7d5YYw3o1&t=634308186300177825
All other servers URL
/WebResource.axd?d=yj6PW1hbOvqhMkOh2gYGlw2&t=634207187366247462
I have checked the web.config, machine.config for every server and they're all identical. The only difference been able to find so far is that prior to the problem commencing, the servers were patched, after which, the problematic server looks to be using different version of the System.Web.dll to the others?
View 2 Replies
May 13, 2010
i have just noticed something strange in some asp.net markup.
I have a standard form with a couple of textboxes and a submit button.
When clicked the code behind will attempt to perform some logic and then return.
If the input values are not valid it used to throw an exception.
The moment i wrapped the controls in an AJAX update panel and try to submit bad data, no exception is thrown and the panel returns like nothing was wrong.
Does anyone know how to return this to the previous behavior whilst keeping the update panel?
View 1 Replies
Mar 5, 2010
I have an ASP.NET page with code-behind in VB.NET. On the ASPX page I have a Repeater with an asp:ImageButton inside the repeater and I want to catch the clicks on the button. As far as I read I have to use FindControl and then handle the copy of the original control:
Codebehind:
Dim imagebutton1 As ImageButton = repeater.FindControl("btnImage1")
AddHandler imagebutton1.Command, AddressOf ReportTransfer
...
...
Protected Sub ReportTransfer(ByVal sender As ImageButton, ByVal args As CommandEventArgs)
...
End Sub
ASPX page:
<td>
<asp:ImageButton runat="server" ID="btnImage1" ImageUrl="~/images/icons/icon_small.png"
CommandArgument="3" />
</td>
</tr>
</ItemTemplate>
It throws "Object reference not set to an instance of an object" on the AddHandler line and I have no idea why it is doing it (I'm a bit new with VB.NET)
View 2 Replies
Oct 8, 2010
I am using a dev express control: ASPxHtmlEditor version 10.1. I am trying to create a simple that only has this control. Unfortunately the control does not render with any of its styles or images loaded. This happens over 20 times. The control does not have any of its styles and all of its images do not load on the control.
I am getting 404 exceptions similar to: "Failed to load source http://localhost:11238/DXR.axd?r=5_0"
View 2 Replies
Dec 1, 2010
I am trying to use page methods to call a function and I am getting a "PageMethods is undefinded" error. I have used them before whilst using C# but not VB so I'm wondering if my syntax is wrong as all examples I can find are C#.I am also wondering if it's because my scriptmanager is on the master page?I've read about this error everywhere but everything I have appears to be correct!
My code:
Part of Master Page
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" EnablePageMethods="true" >
</asp:ScriptManager>[code]....
View 2 Replies
Jan 17, 2011
I am using AjaxToolkit 4.0 which suggests to use ToolkitScriptManager in place of ScriptManager. But when I am using ToolkitScriptManager, it throws javascript exception when Page_ClientValidate() in called from javascript. However, this error is not coming when ScriptManager is used. Can anybody tell me how to make Page_ClientValidate() run when using ToolkitScriptManager?
View 1 Replies