datagridview传值出现“未将对象引用设置到对象的实例。”问题
运行以下代码段总是出现上述问题,请问原因及修改方式
#region 保存dgv中被选中的某一行的所有图书信息
string updateclikedbook_booknum = null;
string updateclikedbook_bookname = null;
string updateclikedbook_booktypename = null;
string updateclikedbook_bookauthor = null;
string updateclikedbook_bookpress = null;
string updateclikedbook_bookpressdate = null;
string updateclikedbook_bookprice = null;
string updateclikedbook_bookplace = null;
string updateclikedbook_bookborrowflag = null;
string updateclikedbook_bookintrodution = null;
string updateclikedbook_booktext = null;
Byte[] imagebytes = null; // 保存图书图片的地址
#endregion
private void dgv_Book_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 0) // 是第一列(选择列)的话,则进行下一步操作
{
updateclikedbook_booknum = this.dgv_Book.Rows[e.RowIndex].Cells[2].Value.ToString();
updateclikedbook_bookname = this.dgv_Book.Rows[e.RowIndex].Cells[3].Value.ToString();
updateclikedbook_booktypename = this.dgv_Book.Rows[e.RowIndex].Cells[4].Value.ToString();
updateclikedbook_bookauthor = this.dgv_Book.Rows[e.RowIndex].Cells[5].Value.ToString();
updateclikedbook_bookpress = this.dgv_Book.Rows[e.RowIndex].Cells[6].Value.ToString();
updateclikedbook_bookpressdate = this.dgv_Book.Rows[e.RowIndex].Cells[7].Value.ToString();
updateclikedbook_bookprice = this.dgv_Book.Rows[e.RowIndex].Cells[8].Value.ToString();
updateclikedbook_bookplace = this.dgv_Book.Rows[e.RowIndex].Cells[9].Value.ToString();
updateclikedbook_bookborrowflag = this.dgv_Book.Rows[e.RowIndex].Cells[10].Value.ToString();
updateclikedbook_bookintrodution = this.dgv_Book.Rows[e.RowIndex].Cells[11].Value.ToString();
updateclikedbook_booktext = this.dgv_Book.Rows[e.RowIndex].Cells[12].Value.ToString();
//Byte[] imagebytes = Convert.ToByte[](this.dgv_Book.Rows[e.RowIndex].Cells[13].Value.ToString());
}
}