Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
string path = Request.Url.Segments[2];
       DataTable dt1=  dsAccessdenied.Tables[0];
       bool flage= false;
       foreach (DataRow row in dt1.Rows)
        {
            string URL = row.ItemArray[0].ToString()
            if (path == URL)
               {
                 flage = true;
               }
        }

in my application i was use this code to avoid certain user those are not able to access this perticular user but it give error.Index was outside the bounds of the array
row.ItemArray[0].ToString() i get error in this line how i should avoid this error suggest me.
Posted
Updated 26-Jul-12 23:17pm
v2
Comments
pradiprenushe 27-Jul-12 5:30am    
Is dsAccessdenied having data?
pradeep040186 27-Jul-12 8:13am    
contain user level url
Sebastian T Xavier 27-Jul-12 5:42am    
Can you check dsAccessdenied.Tables.count ?
pradeep040186 27-Jul-12 8:13am    
yes

Sebastian T Xavier 27-Jul-12 8:30am    
You solved it?.

1 solution

You avoid that checking the row.ItemArray.Length property, that must be at least 1.
 
Share this answer
 
Comments
pradeep040186 27-Jul-12 6:20am    
row.ItemArray.Length instead of that i used only
string URL = row;
CPallini 27-Jul-12 6:36am    
If you don't check the lenght of the array then you may 'go out of bounds'.
As an alternative, you may handle the exception.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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