user3252821
user3252821

Reputation: 11

Get a cell value in gridview selected row

I Implemented the code below it gives a run time error."Input string was not in a correct format".

int ID = int.Parse(grdMnaualEntryTransactionTemplate.SelectedRow.Cells[1].Text)

Upvotes: 0

Views: 764

Answers (2)

Latrova
Latrova

Reputation: 493

try that

int ID = int.Parse(grdMnaualEntryTransactionTemplate.SelectedRow.Cells[1].Value.ToString())

Or...

int ID = (int)grdMnaualEntryTransactionTemplate.SelectedRow.Cells[1].Value;

Upvotes: 0

Mukesh Rawat
Mukesh Rawat

Reputation: 2097

You can check this post also. Error can be occurred due to extra spacing. Try to use .Trim() and check.

Upvotes: 1

Related Questions