.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Post New Web Links

Super Urgent!!Index was outside the bounds of the array

Posted By:      Posted Date: November 29, 2010    Points: 0   Category :ASP.Net

Hi. I am having problem uploading the textfile. It will appear this error. When i upload other files,it is working fine. Could the reason be because the file that i am trying to upload has around 100 columm? Thanks for ur help. Could you paste the code too?

This is the error:

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:

Line 142:        'for loop from 0 to total header element - 1
Line 143: For i As Integer = 0 To preheader.Length - 1 Step 1
Line 144: Dim header1 As String = preheader(i) & trgheader(i) 'header1 = joins up start header and trailin header
Line 145: Dim header2 As String = preheader(i) & " " & trgheader(i) 'header2 = joins up start header

View Complete Post

More Related Resource Links

Index was outside the bounds of the array.

hi..i create registration form in asp.net & sql server..after fill up form when i click save button it's show error..here is my code :-private void ExecuteInsert(string AccNo, string CompanyName, string Desc2, string RegisterNo, string Address1, string Address2, string Address3, string Address4, string PostCode, string DeliverAddr1, string DeliverAddr2, string DeliverAddr3, string DeliverAddr4, string DeliverPostCode, string Attention, string Phone1, string Phone2, string Fax1, string Fax2, string AreaCode, string SalesAgent, string DebtorType, string NatureOfBusiness, string WebURL, string EmailAddress, string DisplayTerm, string UDF_Shipvia, string UDF_freigh, string UDF_SourceIn, string UDF_ProductEnq, string CurrencyCode)    {        SqlConnection conn = new SqlConnection(GetConnectionString());        string sql ="INSERT INTO Debtor (AccNo, CompanyName, Desc2, RegisterNo, Address1, Address2, Address3, Address4, PostCode, CreditLimit, CurrencyCode, DeliverAddr1, DeliverAddr2, DeliverAddr3, DeliverAddr4, DeliverPostCode, Attention, Phone1, Phone2, Fax1, Fax2, AreaCode, SalesAgent, DebtorType, NatureOfBusiness, WebURL, EmailAddress, DisplayTerm, UDF_Shipvia, UDF_freigh, UDF_ProductEnq, UDF_SourceIn) VALUES " + " (@AccNo, @CompanyName, @Desc2, @RegisterNo, @Address1, @Ad

Index was outside the bounds of the array.


why I am getting this error when trying to run the application with no argument although I set the if function? how can I solve it plz?


static void Main(string[] args)
  Control.CheckForIllegalCrossThreadCalls = false;

  if (args[0] == null)
    Application.Run(new frmSplash());
    Application.Run(new frmMain());

Jassim Rahma

URGENT - Run out of HD space whilst rebuilding an index

I just altered a table on my large SQL server 2000 database and now the database has been offline for ages and the hard drive as run out of space because of the transaction log size.What can I do!  Enterprise manager has frozen me out completely and theres nothing else I can delete to free up space whist this completes.I've not received any kind of warning and the HD is still being accessed by SQLserver.Do you think this will eventually complete?  Should I stop the SQL service.  HELP

Sort Array along with its Corresponding index



  I have a one-d Array named zz containing {5,3,8,1,9,6}. Current order of indices of the elements is : 0,1,2,3,4,5. 

Now I want to sort the array z in ascending order in such a way that its corresponding indices also sort according to its respective elements.

Ex: Elts in Ascending order : 1,3,5,6,8,9

and Respective indices will be : 3,1,0,5,2,4.

Another Ex: What "Additions" should i make to the following code, if the Array Element repeats ??  Epected Oreder of Indices : 1,0,4,3,2

int[] A = new int[6] { 3, 2, 8, 5, 3 };  //{ 5, 3, 8, 1, 9, 6 };
            int[] B = new int[6];
            int[] index = new int[6];
            int flag = 0;
            Console.WriteLine("Array A:");
            for (int i = 0; i < A.Length; i++)

Finding an array index by giving a maximum value


Hi there,

.Net 4.0 C#

1) I have an int Array {5, 10, 1, 40, 110, 120, 12, 70}
2) I have an external number ie. 44

Without using loops, is there a possibility to find the index of the highest value in the array that must be lower or equal than the external number (in this case 40, or index 3)?

thx in adv.


Binding an array to dropdown list


I have the following string which is a list of urls. How do I get this to work so the url shows for the selection and also is the value?      


allLinks = newAllLinks
        Me.DropDownList1.DataTextField = "Link"
        Me.DropDownList1.DataValueField = "LinkURL"
        Me.DropDownList1.Items.Insert(0, New ListItem(" - Select - ", 0))
        Me.DropDownList1.DataSource = allLinks


 ArgumentNullException: Value cannot be null.
Parameter name: container]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +121
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8

how to get an array of all the asp.net textbox control inside create user wizard control?



How can I get all the textboxes inside a create user wizard control using getElementsByTagName().

Below is my JQuery code:

<script type="text/javascript">
        function addLoadEvent(func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function() {

        function prepareInputsForHints() {
            var inputs = document.getElementsByTagName("asp:TextBox");
            for (var i = 0; i < inputs.length; i++) {
                inputs[i].onfocus = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
                inputs[i].onblur = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "none";



<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

How to cast integer values as an array of enum values?


Hello all!

I'm working with VS2010 Beta2, ASP.NET and Dynamic Data. I'm using VB but will certainly be happy to receive a C# example if necessary. Laughing

I used a few of Steve's examples (Writing Attributes and Extension Methods for Dynamic Data and Dynamic Data - Hiding Columns in selected PageTemplates) to create a custom property attribute to be applied to a dynamic data column and want it to accept an array of enum values (each value will represent a dynamic data page template where this column should not be displayed).  My new attribute works fine when I hardcode it like this, meaning the HideColumnIn attribute is properly populated with the array of enum values:

<HideColumnIn(PageTemplate.List, PageTemplate.Edit)> _
Public Property My_DD_Column As Object


However, I want to store the values to be used for the HideColumnIn in the DB as integer values that correspond to the

Unity - Inject array



I have the following in the config file...

container.RegisterType<ProductInstanceValidatorBase, CartItemStockValidator>();
container.RegisterType<ProductInstanceValidatorBase, MonthlyCartItemValidator>();

..constructor like so...

 public CartValidator(ProductInstanceValidatorBase[] validators)
   this.validators = validators;

...I call the following but the array is empty...


Any ideas?

Cheers, WT.



Converting ReportDocument object into byte array ?


Hi All,

          Is it possible to convert the Report Document object as a byte array and store it in SQL , later retrieve and assing it to a report ?


Invalid length for a Base-64 char array for my coding in ASP.net C#. How to solve it ?


Hi Friends ,

I have done encrypted password and decode but i got error  like  this  " Invalid length for a Base-64 char array" .

Pls help . Thanks


psswd = txtPassword.Text;

pwed = base64Decode(psswd);

public string base64Decode(string sData)
            System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
            System.Text.Decoder utf8Decode = encoder.GetDecoder();
            byte[] todecode_byte = Convert.FromBase64String(sData);
            int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
            char[] decoded_char = new char[charCount];
            utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
            string result = new String(decoded_char); return result;

Class which contains an array of objects of type "Class2"



1  Partial Class _Default
2  Inherits System.Web.UI.Page

3 Public Function Ohjoy(ByVal X As Integer) As Integer
4 Dim theClass As New Class1 '= New Class1()
5    theClass.ReSize(0)
6    theClass.myBaby(0).GetName(0) = "Hello" 'Property Chars is read only'
7    Return 1
8 End Function
I have a first class named "Class1". I have a second class named "Class2" Class2, is a member of class 1,
and is implemented as an array of objects of type Class 2.

If I try and call the Accessor GetName() my hard coded value "Hello" in my accessor is not returned? Only
an alpha character like "T"

Also if I try and assigne a value using the setter GetName() it does not work, and the compiler gives me
an error message "property Chars is ReadOnly? Does anyone know what is wrong in my code? Line 6 above


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class

Public Class Class1
    Dim bs As Integer
    Public myBaby() As Class2
    Public myB As Class2
    Public Function ReSize(By

Query an arraylist of array list using linq


I have an array list called Customer. I t holds a list of array list which has the account details.

proj.customer -> collection of arraylist of type customer

proj.customer.account -> collection of arraylist of type account

Account array list holds type account and it has a poperty account balance. How can I query all accounts which has account balance  >100

I tried the following one

var Accountlist= from Account accountdetails in proj.customer.account

where accountid.balance >100

select accountdetails.id

But it is always throwing an error saying cannot cast type customer to type account

Please help

Basic Instincts: Collection and Array Initializers In Visual Basic 2010


Collection Initializers are a great addition to the language and allows concise syntax in order to initialize both framework and user defined collection types.

Spotty Bowles

MSDN Magazine October 2009

Array List with unique id while adding student info

Hello Frds,

I'm having arraylist to add student info but i have to create unique id per record below is my class.

Student objStudent=new Student(123,"Nj");

public class Student
  private string name;
private int RollId;
public string Name

    get { return name; }
set { name = value; }

public int Id
    get { return RollId; }
set { RollId = value; }
public Employee(string name, int id)


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend