0

I have a VB page with a gridview on it. The gridview allows the user to add a value and update the DB with it. THe type is Double. How do I set the value of the cell to NULL if the user changes a value from a number to blank. for example the gridview has the value of 10 in it and they delete it I want the DB to go back to NULL.

I have tried the following but it doesnt change anything.

If text = "" Then
                    amendedvalue = Nothing
                Else
                    amendedvalue = CDbl(CType(gv.Rows(x).Cells(2).FindControl("txtstartH"), TextBox).Text)

                    UpdateData(amendedvalue, id)
                End If
4

1 回答 1

0
If text = "" Then
    UpdateData(DBNull.Value, id)
Else
    amendedvalue = CDbl(CType(gv.Rows(x).Cells(2).FindControl("txtstartH"), TextBox).Text)
    UpdateData(amendedvalue, id)
End If

This will fix your problem

于 2013-05-07T09:36:55.977 回答