Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

when writing value in first cell of datagridview win form it give error index was out of range Must be non-negative and less than the size of the collection

$
0
0

Problem

I have datagridview have cell 0 is MembershipNo when write any value on datagridview give me error 

index was out of range  Must be non-negative and less than the size of the collection why and how to solve that .

Exception error happen on cell click event of datagridview on function UpdateMemberCode

  private void gridClassPlayers_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (gridClassPlayers.CurrentRow != null)
            {
                         UpdateMemberCode(gridClassPlayers.SelectedCells[0].Value.ToString());
            }
        }

 private void UpdateMemberCode(string MemberCodeVal)
        {

            string sql = " Update ClubTransactionType SET MemberCode =" + MemberCodeVal + "  WHERE TrxTypeID =" + GetTransaction + " AND LineNumber=1";
            DataAccess.ExecuteNonQuery(sql);

        }


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>