I am using radgridview(winform) to display table values. I have a CellClick event for launching links for a particular column. The problem is that when I click to sort column at 3rd attempt it gives me error "Object Reference not set to instance of obj". While the users get error on every attempt after the first attempt. Here is my code -
private void radGridView1_CellClick(object sender, GridViewCellEventArgs e){
index = radGridView1.CurrentCell.ColumnIndex;
if(radGridView1.Columns[e.ColumnIndex].Name.Equals("ColumnName")
&& index > 0)
{
Process.Start("http://www..../" + radGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value as string);
}
}
I cannot figure out as why I am getting this error & how to resolve it. I tried to debug but every time I find index to be 0 and not null when I click the column header.
SOLUTION:
Instead of using ColumnIndex it should be e.rowindex
index = e.RowIndex;
if(radGridView1.Columns[e.ColumnIndex].Name.Equals("ColumnName")
&& index != -1)