I'm quite new to asp.net so maybe I'm trying something stupid (just tell)
Have a gridview with about 15 databound columns, 4 of the columns are editable and 1 templatefield.
In the databound event, I make a new database connection (sqladapter that fills a dataset).
I do comparisons between the gridview values and the values retrieved from the database. If condition is raised I fill a templatefield in the gridview.
if
(Convert.ToDecimal(datarow[0].ToString()) > Convert.ToDecimal(e.Row.Cells[11].Text))
{
e.rows.cell[16].text = ' My message to user';
}
No problem so far.
The problem occurs if the gridview field in the comparison is enabled (not read only).
In that case, the edit button doesn't work. If I click on it, the row doensn't go into edit mode.
At first I thought there was some strange value in the cell, which couldn't be converted to a decimal. But after setting the column to readonly = true, the problem went away.
When I start the page in debugmode, an error is raised on the moment I click the edit link.
FormatException was unhandled by user code. Input string was not in correct format.
Very strange, this error occurs only on enabled fields.
I thought to solve the problem, by checking on the rowstate and execute code the code only in the normal state. However databound event is not executed when I click on the edit button, so why is error raised in the databound event when it's not even raised?
Known issue? What am I doing wrong? Workaround?
Appreciate any advice.