You must Sign In to post a response.
  • Category: Windows

    Index was out of range. Must be non-negative and less than the size of the collection. Parameter nam

    I am developing c# windows application using data grid view, i am retrieve my stored data for grid view, but error is came. this is for my first column code,

    dgvfind.Columns[0].HeaderText = "SL NO";
    dgvfind.Columns[0].Name = "SL NO";
    dgvfind.Columns[0].DataPropertyName = "slno";

    but error is came first line.
    Hide Copy Code
    Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index, Any one please guide me.
  • #767350
    Hi Boopal,

    As per error details you are trying to call the out side range index, that means in your result table you don't have any records but you are trying to call 0th index that time you got this type of error, to resolve this type of issues before accessing the index, just check one condition whether the result table contains that index or not, so that you can avoid this type of issues.

    Hope this will helpful to you..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments