Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void gridCountry_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        
        obj1.CountryId = Convert.ToInt32(gridCountry.DataKeys[e.RowIndex]["CountryId"].ToString ());
        obj1.DataDeleteInsideAllTable();
        obj1.ddlCountryListgrid(gridCountry);
    }

obj1.CountryId = Convert.ToInt32(gridCountry.DataKeys[e.RowIndex][CountryId].ToString ());
Why this particular line gives following error ?
Quote:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Thanks for Help in Advance.
Posted
Comments
[no name] 18-Jul-13 7:06am    
obj1.CountryId = Convert.ToInt32(gridCountry.DataKeys[e.RowIndex-1]["CountryId"].ToString ());

You try this Code
Rambo_Raja 18-Jul-13 7:30am    
hey i have already done that...
Have you tried Solution 1?

1 solution

C#
obj1.CountryId = Convert.ToInt32(gridCountry.DataKeys[e.RowIndex].Values["CountryId"].ToString ());
 
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