Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
See more: C#3.0Oracle
I m working on an web application which gives information of user which use specific mailing system
i get user name, mobilenumber,...., account lock status of user from oracle database.
this information is diplayed in Grid.
this is bound to webpage at runtime.
i m using web service to bind datagrid to page at runtime
i m asked to add one more column to this grid with name "Unlock user" which contains a link.
if 'account lock status' value taken from database is "Y" then i need to show the "unlock link" in "Unlock Column" else show nothing.
i have bound the column to grid and I fulfilled above condition too
I have bound this column using XML document.

but my problem is the above program runs fine for some time
that is when i click unlock button the program works fine
when i do this for 3 or more time(not fixed) even for first time also i get following error

"
SQL
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

"
at line
C#
public void DisableControls()
   {
       // Disable All Controls Not Required for View Only
       BtnAdd.Visible = false;
       FlexiGrid1.Items[7].Hide = true;//At this line i m getting exception but when i click F5 the program works fine .
  }

the exception goes and again when i try to load page again sometimes it shows above exception again and when i click F5 program runs

I m not understanding when i click F5 then exception goes although i dont do anything then why its coming and to remove this what should i do?
Posted
Updated 7-Aug-11 19:41pm
v3
Comments
Sergey Alexandrovich Kryukov 8-Aug-11 1:41am    
The relevant code is not there. How anyone could help you to find the bug. Run it under debugger and find out where is happens; or catch all exceptions on top of stack frame and get full exception dump; post it with relevant part of code, indicate source code lines where it happens. Act.
--SA

The error means what it says. Why on earth are you writing code that accesses fields by index, without checking first if they are there, or even better, accessing them by a name that is easily read and understood ? Obviously the number of rows in your grid is changing and the 8th row is not there. I'm not sure what else you expect us to tell you.
 
Share this answer
 
Make sure this items exists.

Put a check in the same if condition to ensure that this value exists and if it does, hide it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900