Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to clear value in datagrid cell

Status
Not open for further replies.

HRHK

Programmer
Jun 5, 2005
83
US
On a datagrid, I have columns request quantity and grant quantity.
If user enters grant qty greater than request quantity, I want to display
message "Grant Qty cannot be greater than Request Qty" and clear grant qty value and put the focus on that column.
I tried setting grant qty to be dbnull.value, but it's not working.
What's the proper way to do this? I would be thankful.




If grdDetails.CurrentCell.ColumnNumber = 6 Then
Dim reqQty As Decimal = grdDetails.Item(currentRow, currentColumn - 3)

Dim tb As TextBox = GetEmbeddedTextBox(dgcc.ColumnNumber)
If Not (tb Is Nothing) Then
Dim oldValue As String = Me.grdDetails(dgcc).ToString()
Dim newValue As String = tb.Text
If newValue <> oldValue Then

If newValue < reqQty Then
blnGrntQtyIsChanged = True
Else
grdDetails.Item(currentRow, currentColumn) = DBNull.Value
MsgBox("Grant Qty cannot be greater than Request Qty", MsgBoxStyle.Information)
End If

End If

End If
End If

 
try using cells collection and setting text or value to string.empty

something like this

grdPatEdLog.Rows[currentRow].Cells[ColumnNumber].Value=string.empty;//this maybe columnnumber-1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top