Need to check after getting the value of qtydelivered, if that is null or empty then return else execute the code for inserting.
Protected Sub btnSubmit_Click(sender As Object, e As ImageClickEventArgs)
Dim constr As String = ConfigurationManager.ConnectionStrings("ConnString").ToString()
For Each row As GridViewRow In DelGView.Rows
Dim sonum As String = DirectCast(row.Cells(1).FindControl("lblSONumber"), Label).Text
Dim itemname As String = DirectCast(row.Cells(2).FindControl("lblItemName"), Label).Text
Dim qty As String = DirectCast(row.Cells(3).FindControl("lblQtyOrdered"), Label).Text
Dim qtydelivered As String = DirectCast(row.Cells(4).FindControl("lblQtyDelivered"), Label).Text
If qtydelivered <> String.Empty AndAlso qtydelivered IsNot Nothing Then
Using con As New SqlConnection(constr)
con.Open()
Dim SqlString As String = "Insert into S_Del( SNo,ItemName,QTYOrdered, QtyDelivered) Values(@SNo,@ItemName,@QTYOrdered, @QTYDelivered)"
Using cmd As New SqlCommand(SqlString, con)
cmd.Parameters.Add("@SNo", SqlDbType.VarChar).Value = sonum
cmd.Parameters.Add("@ItemName", SqlDbType.VarChar).Value = itemname
cmd.Parameters.AddWithValue("@QTYOrdered", qty)
cmd.Parameters.AddWithValue("@QTYDelivered", qtydelivered)
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
End Using
End Using
Else
End If
Next
End Sub